Commit e542dde8 authored by Rafael Laya's avatar Rafael Laya Committed by Carles Cufi
Browse files

drivers: regulator: add tests for get_max/min voltage

Adds unit tests to make sure get_max and get_min voltage
remain healthy

Signed-off-by: default avatarRafael Laya <rafael_laya97@hotmail.com.com>
parent cda19bda
Loading
Loading
Loading
Loading
+26 −0
Changes for tests/drivers/regulator/api/src/main.c: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -777,6 +777,32 @@ static int get_error_flags_fail(const struct device *dev,
	return -EIO;
}

ZTEST(regulator_api, test_get_max_voltage)
{
	int32_t max_uv = 0;
	int err = 0;

	err = regulator_common_get_max_voltage(reg0, &max_uv);
	zassert_equal(err, -ENOENT);

	err = regulator_common_get_max_voltage(reg3, &max_uv);
	zassert_equal(err, 0);
	zassert_equal(max_uv, 200);
}

ZTEST(regulator_api, test_get_min_voltage)
{
	int32_t min_uv = 0;
	int err = 0;

	err = regulator_common_get_min_voltage(reg0, &min_uv);
	zassert_equal(err, -ENOENT);

	err = regulator_common_get_min_voltage(reg3, &min_uv);
	zassert_equal(err, 0);
	zassert_equal(min_uv, 100);
}

ZTEST(regulator_api, test_get_error_flags_error)
{
	RESET_FAKE(regulator_fake_get_error_flags);