Skip to content

Commit 0dcc637

Browse files
jukkarioannisg
authored andcommitted
tests: kernel: Add unit test for sys_put_be64()
Make sure sys_put_be64() works as expected. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 78825ed commit 0dcc637

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/kernel/common/src/byteorder.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ void test_sys_get_be64(void)
8686
zassert_equal(tmp, val, "sys_get_be64() failed");
8787
}
8888

89+
/**
90+
* @brief Test sys_put_be64() functionality
91+
*
92+
* @details Test if sys_put_be64() correctly handles endianness.
93+
*
94+
* @see sys_put_be64()
95+
*/
96+
void test_sys_put_be64(void)
97+
{
98+
u64_t val = 0xf0e1d2c3b4a59687;
99+
u8_t buf[] = {
100+
0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87
101+
};
102+
u8_t tmp[sizeof(u64_t)];
103+
104+
sys_put_be64(val, tmp);
105+
106+
zassert_mem_equal(tmp, buf, sizeof(u64_t), "sys_put_be64() failed");
107+
}
108+
89109
/**
90110
* @}
91111
*/

tests/kernel/common/src/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
extern void test_byteorder_memcpy_swap(void);
1414
extern void test_byteorder_mem_swap(void);
1515
extern void test_sys_get_be64(void);
16+
extern void test_sys_put_be64(void);
1617
extern void test_atomic(void);
1718
extern void test_intmath(void);
1819
extern void test_printk(void);
@@ -97,6 +98,7 @@ void test_main(void)
9798
ztest_unit_test(test_byteorder_memcpy_swap),
9899
ztest_unit_test(test_byteorder_mem_swap),
99100
ztest_unit_test(test_sys_get_be64),
101+
ztest_unit_test(test_sys_put_be64),
100102
ztest_user_unit_test(test_atomic),
101103
ztest_unit_test(test_bitfield),
102104
ztest_unit_test(test_printk),

0 commit comments

Comments
 (0)