20 const int kTestData[] = {2, 0, 12, 1, 1, 2, 10, 1, 0, 0, 0, 2, 0, 4, 1, 1};
22 class STATSTest :
public testing::Test {
25 std::locale::global(std::locale(
""));
26 stats_.set_range(0, 16);
27 for (
size_t i = 0; i <
ARRAYSIZE(kTestData); ++i)
28 stats_.add(i, kTestData[i]);
37 TEST_F(STATSTest, BasicStats) {
38 EXPECT_EQ(37, stats_.get_total());
39 EXPECT_EQ(2, stats_.mode());
40 EXPECT_EQ(12, stats_.pile_count(2));
44 TEST_F(STATSTest, TopNModes) {
46 int num_modes = stats_.top_n_modes(3, &modes);
47 EXPECT_EQ(3, num_modes);
49 EXPECT_FLOAT_EQ(2.0f + 3.0f / 14, modes[0].key);
50 EXPECT_EQ(14, modes[0].data);
52 EXPECT_FLOAT_EQ(5.0f + 12.0f / 13, modes[1].key);
53 EXPECT_EQ(13, modes[1].data);
55 EXPECT_FLOAT_EQ(13.5f, modes[2].key);
56 EXPECT_EQ(6, modes[2].data);