diff options
Diffstat (limited to 'libs/battery/MultiStateCounterTest.cpp')
| -rw-r--r-- | libs/battery/MultiStateCounterTest.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libs/battery/MultiStateCounterTest.cpp b/libs/battery/MultiStateCounterTest.cpp index 876bf745a8..cb11a5444d 100644 --- a/libs/battery/MultiStateCounterTest.cpp +++ b/libs/battery/MultiStateCounterTest.cpp @@ -210,6 +210,26 @@ TEST_F(MultiStateCounterTest, updateValue_nonmonotonic) { EXPECT_DOUBLE_EQ(3.0, delta); } +TEST_F(MultiStateCounterTest, incrementValue) { + DoubleMultiStateCounter testCounter(2, 0); + testCounter.updateValue(0, 0); + testCounter.setState(0, 0); + testCounter.updateValue(6.0, 2000); + + testCounter.setState(1, 3000); + + testCounter.incrementValue(8.0, 6000); + + // The total accumulated count is: + // 6.0 // For the period 0-2000 + // +(8.0 * 0.25) // For the period 3000-4000 + EXPECT_DOUBLE_EQ(8.0, testCounter.getCount(0)); + + // 0 // For the period 0-3000 + // +(8.0 * 0.75) // For the period 3000-4000 + EXPECT_DOUBLE_EQ(6.0, testCounter.getCount(1)); +} + TEST_F(MultiStateCounterTest, addValue) { DoubleMultiStateCounter testCounter(1, 0); testCounter.updateValue(0, 0); |