zephyr: Add tests for `st_get_resolution()` and `st_get_data_rate()`
Add unit tests for `st_get_resolution()` and `st_get_data_rate()`.
BRANCH=None
TEST=zmake configure --test zephyr/test/drivers
@@ -172,6 +172,44 @@ static void test_st_write_data_with_mask(void)
"mock_write_fn was not called.");
}
+static void test_st_get_resolution(void)
+{
+ int expected_resolution = 123;
+ int rv;
+
+ struct stprivate_data driver_data = {
+ .resol = expected_resolution,
+ };
+
+ const struct motion_sensor_t sensor = {
+ .drv_data = &driver_data,
+ };
+
+ rv = st_get_resolution(&sensor);
+ zassert_equal(rv, expected_resolution, "rv is %d but expected %d", rv,
+ expected_resolution);
+}
+
+static void test_st_get_data_rate(void)
+{
+ int expected_data_rate = 456;
+ int rv;
+
+ struct stprivate_data driver_data = {
+ .base = {
+ .odr = expected_data_rate,
+ },
+ };
+
+ const struct motion_sensor_t sensor = {
+ .drv_data = &driver_data,
+ };
+
+ rv = st_get_data_rate(&sensor);
+ zassert_equal(rv, expected_data_rate, "rv is %d but expected %d", rv,
+ expected_data_rate);
+}
+
void test_suite_stm_mems_common(void)
{
ztest_test_suite(
@@ -181,6 +219,8 @@ void test_suite_stm_mems_common(void)
ztest_unit_test_setup_teardown(test_st_raw_read_n_noinc, setup,
unit_test_noop),
ztest_unit_test_setup_teardown(test_st_write_data_with_mask,
- setup, unit_test_noop));
+ setup, unit_test_noop),
+ ztest_unit_test(test_st_get_resolution),
+ ztest_unit_test(test_st_get_data_rate));
ztest_run_test_suite(stm_mems_common);
}
