68 EXPECT_CALL(mockI2C, readRegister(0x02)).WillOnce(Return(1000));
69 EXPECT_CALL(mockI2C, readRegister(0x01)).WillOnce(Return(100));
71 float busVoltage = (1000 >> 3) * 0.004f;
72 float shuntVoltage = 100 * 0.01f;
73 float loadVoltage = busVoltage + shuntVoltage;
74 float expectedPercentage = (loadVoltage - 6.0f) / 2.4f * 100.0f;
76 if (expectedPercentage > 100.0f)
77 expectedPercentage = 100.0f;
78 if (expectedPercentage < 0.0f)
79 expectedPercentage = 0.0f;
81 float percentage = batteryController->getBatteryPercentage();
82 EXPECT_NEAR(percentage, expectedPercentage, 0.1f);