File: HistogramTest.cpp

package info (click to toggle)
abyss 2.3.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,284 kB
  • sloc: cpp: 78,182; ansic: 6,512; makefile: 2,252; perl: 672; sh: 509; haskell: 412; python: 4
file content (53 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Common/Histogram.h"
#include "gtest/gtest.h"


// test Histogram.empty()
TEST(emptyTest, base_cases)
{
	Histogram hi;
	EXPECT_TRUE(hi.empty());
	hi.insert(2);
	EXPECT_FALSE(hi.empty());
	hi.insert(4);
	EXPECT_FALSE(hi.empty());
}

// test Histogram.count()
TEST(countTest, non_negative_cases)
{
	Histogram hi;
	hi.insert(2);
	hi.insert(4);
	EXPECT_EQ(hi.size(), (unsigned)2);
	hi.insert(6);
	hi.insert(8);
	hi.insert(10, 5);
	EXPECT_EQ(hi.size(), (unsigned)9);
	EXPECT_EQ(hi.count(INT_MIN, INT_MAX), (unsigned)9);
	EXPECT_EQ(hi.count(8, 10), (unsigned)6);
	hi.insert(12);
	EXPECT_EQ(hi.size(), (unsigned)10);
	EXPECT_EQ(hi.count(INT_MIN, INT_MAX), (unsigned)10);
}

// test Histogram.sum()
TEST(sumTest, trivial_cases)
{
	Histogram hello;
	EXPECT_EQ(hello.sum(), (unsigned)0);
}

// test Histogram.removeNoise()
TEST(removeNoise, one_entry)
{
	Histogram hi;
	hi.insert(10, 5);
	EXPECT_EQ(hi.size(), 5u);
	hi.removeNoise();
	EXPECT_EQ(hi.size(), 5u);
	hi.insert(20, 10);
	EXPECT_EQ(hi.size(), 15u);
	hi.removeNoise();
	EXPECT_EQ(hi.size(), 10u);
}