Skip to content

Commit 8b69b79

Browse files
JordanYatesnashif
authored andcommitted
tests: fuel_gauge: test negative current
Validate that the SBS fuel gauge driver returns the expected values for negative currents (discharging). Signed-off-by: Jordan Yates <[email protected]>
1 parent 8345775 commit 8b69b79

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/drivers/fuel_gauge/sbs_gauge/src/test_sbs_gauge.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,24 @@ ZTEST_USER_F(sbs_gauge_new_api, test_get_buffer_props__returns_ok)
206206
ZTEST_USER_F(sbs_gauge_new_api, test_charging_5v_3a)
207207
{
208208
uint32_t expected_uV = 5000 * 1000;
209-
uint32_t expected_uA = 3000 * 1000;
209+
int32_t expected_uA = 3000 * 1000;
210+
211+
union fuel_gauge_prop_val voltage;
212+
union fuel_gauge_prop_val current;
213+
214+
zassume_ok(emul_fuel_gauge_set_battery_charging(fixture->sbs_fuel_gauge, expected_uV,
215+
expected_uA));
216+
zassert_ok(fuel_gauge_get_prop(fixture->dev, FUEL_GAUGE_VOLTAGE, &voltage));
217+
zassert_ok(fuel_gauge_get_prop(fixture->dev, FUEL_GAUGE_CURRENT, &current));
218+
219+
zassert_equal(voltage.voltage, expected_uV, "Got %d instead of %d", voltage, expected_uV);
220+
zassert_equal(current.current, expected_uA, "Got %d instead of %d", current, expected_uA);
221+
}
222+
223+
ZTEST_USER_F(sbs_gauge_new_api, test_charging_5v_neg_1a)
224+
{
225+
uint32_t expected_uV = 5000 * 1000;
226+
int32_t expected_uA = -1000 * 1000;
210227

211228
union fuel_gauge_prop_val voltage;
212229
union fuel_gauge_prop_val current;

0 commit comments

Comments
 (0)