1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/dram/ddr4.h>
4 #include <tests/test.h>
6 static void ddr4_speed_mhz_to_mts_test(void **state
)
8 assert_int_equal(0, ddr4_speed_mhz_to_reported_mts(0));
9 assert_int_equal(0, ddr4_speed_mhz_to_reported_mts(667));
11 assert_int_equal(1600, ddr4_speed_mhz_to_reported_mts(668));
12 assert_int_equal(1600, ddr4_speed_mhz_to_reported_mts(800));
14 assert_int_equal(1866, ddr4_speed_mhz_to_reported_mts(801));
15 assert_int_equal(1866, ddr4_speed_mhz_to_reported_mts(933));
16 assert_int_equal(1866, ddr4_speed_mhz_to_reported_mts(934));
18 assert_int_equal(2133, ddr4_speed_mhz_to_reported_mts(1066));
19 assert_int_equal(2133, ddr4_speed_mhz_to_reported_mts(1067));
21 assert_int_equal(2400, ddr4_speed_mhz_to_reported_mts(1200));
23 assert_int_equal(2666, ddr4_speed_mhz_to_reported_mts(1333));
25 assert_int_equal(2933, ddr4_speed_mhz_to_reported_mts(1466));
27 assert_int_equal(3200, ddr4_speed_mhz_to_reported_mts(1467));
28 assert_int_equal(3200, ddr4_speed_mhz_to_reported_mts(1600));
30 assert_int_equal(0, ddr4_speed_mhz_to_reported_mts(1601));
31 assert_int_equal(0, ddr4_speed_mhz_to_reported_mts(INT16_MAX
));
36 const struct CMUnitTest tests
[] = {cmocka_unit_test(ddr4_speed_mhz_to_mts_test
)};
38 return cb_run_group_tests(tests
, NULL
, NULL
);