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: Rafael Laya <rafael_laya97@hotmail.com.com>
This commit is contained in:
Rafael Laya 2024-10-21 06:10:36 -07:00 committed by Carles Cufí
parent cda19bdab6
commit e542dde890
1 changed files with 26 additions and 0 deletions

View File

@ -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);