summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/src/stm_mems_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/drivers/src/stm_mems_common.c')
-rw-r--r--zephyr/test/drivers/src/stm_mems_common.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/zephyr/test/drivers/src/stm_mems_common.c b/zephyr/test/drivers/src/stm_mems_common.c
index 701a573f79..8ae5d860bf 100644
--- a/zephyr/test/drivers/src/stm_mems_common.c
+++ b/zephyr/test/drivers/src/stm_mems_common.c
@@ -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);
}