summaryrefslogtreecommitdiff
path: root/libs/battery/MultiStateCounterTest.cpp
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2024-06-20 20:42:50 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-06-20 20:42:50 +0000
commit3dd03323aa8825a0c7bf4dcc1ed6d6c3b88a3d7f (patch)
treee05639565a22611c334a83a35a998f3fba3e1f1a /libs/battery/MultiStateCounterTest.cpp
parent447d0a33acc9827809d1049023b05e4cac05fc70 (diff)
parentbb1814a0b94e8efb3fa3843c3d6a6533a382cac3 (diff)
Merge "Merge 24Q3 (ab/11976889) to aosp-main-future" into aosp-main-future
Diffstat (limited to 'libs/battery/MultiStateCounterTest.cpp')
-rw-r--r--libs/battery/MultiStateCounterTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/battery/MultiStateCounterTest.cpp b/libs/battery/MultiStateCounterTest.cpp
index cb11a5444d..a51a38a6c7 100644
--- a/libs/battery/MultiStateCounterTest.cpp
+++ b/libs/battery/MultiStateCounterTest.cpp
@@ -72,6 +72,22 @@ TEST_F(MultiStateCounterTest, stateChange) {
EXPECT_DOUBLE_EQ(4.0, testCounter.getCount(2));
}
+TEST_F(MultiStateCounterTest, copyStatesFrom) {
+ DoubleMultiStateCounter sourceCounter(3, 0);
+
+ sourceCounter.updateValue(0, 0);
+ sourceCounter.setState(1, 0);
+ sourceCounter.setState(2, 1000);
+
+ DoubleMultiStateCounter testCounter(3, 0);
+ testCounter.copyStatesFrom(sourceCounter);
+ testCounter.updateValue(6.0, 3000);
+
+ EXPECT_DOUBLE_EQ(0, testCounter.getCount(0));
+ EXPECT_DOUBLE_EQ(2.0, testCounter.getCount(1));
+ EXPECT_DOUBLE_EQ(4.0, testCounter.getCount(2));
+}
+
TEST_F(MultiStateCounterTest, setEnabled) {
DoubleMultiStateCounter testCounter(3, 0);
testCounter.updateValue(0, 0);