Esempio n. 1
0
TEST(StatsTest, CounterSimpleTest) {
  Counter c;
  c.record(-7);
  EXPECT_EQ(1, c.getCount());
  EXPECT_EQ(-7, c.getMin());
  EXPECT_EQ(-7, c.getMax());
  EXPECT_EQ(-7.0, c.getAverage());
  c.record(-9);
  EXPECT_EQ(2, c.getCount());
  EXPECT_EQ(-9, c.getMin());
  EXPECT_EQ(-7, c.getMax());
  EXPECT_EQ(-8.0, c.getAverage());
  ostringstream oss;
  c.print(oss);
  EXPECT_EQ(oss.str(), "2,-8,-9,-7,1");
}
Esempio n. 2
0
TEST(StatsTest, CounterNoData) {
  Counter c;
  EXPECT_EQ(0, c.getCount());
  EXPECT_TRUE(std::isnan(c.getAverage()));
  ostringstream oss;
  c.print(oss);
  std::string res = oss.str();
  EXPECT_EQ(res, "0,nan,0,0,0");
}