From c99e160261c2a443f61de8e073497cce1542821e Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 11 Jun 2024 11:16:38 +0200 Subject: pb-write + tests --- test/pbdrv/write.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'test/pbdrv') diff --git a/test/pbdrv/write.cpp b/test/pbdrv/write.cpp index 31e5d8d..ad775bb 100644 --- a/test/pbdrv/write.cpp +++ b/test/pbdrv/write.cpp @@ -2,9 +2,57 @@ #include "pb-write.h" +TEST(pbdrv, write_cmd_req_read) { + pbdrv_buf_t buf = pbdrv_write_cmd_req_read({ + .propid = 0, + }); + + ASSERT_NE(buf.data, nullptr); + ASSERT_GE(buf.size, 0); +} + +TEST(pbdrv, write_cmd_res_read) { + pbdrv_buf_t buf = pbdrv_write_cmd_res_read({ + .propid = 0, + .value = (uint8_t[]) { 0x00, }, + ._value_size = 1, + }); + + ASSERT_NE(buf.data, nullptr); + ASSERT_GE(buf.size, 0); +} + +TEST(pbdrv, write_cmd_req_write) { + pbdrv_buf_t buf = pbdrv_write_cmd_req_write({ + .propid = 0, + .value = (uint8_t[]) { 0x00, }, + ._value_size = 1, + }); + + ASSERT_NE(buf.data, nullptr); + ASSERT_GE(buf.size, 0); +} + +TEST(pbdrv, write_cmd_req_state) { + pbdrv_buf_t buf = pbdrv_write_cmd_req_state({ + .state = PB_GS_PLAYING, + }); + + ASSERT_NE(buf.data, nullptr); + ASSERT_GE(buf.size, 0); +} + +TEST(pbdrv, write_cmd_res_state) { + pbdrv_buf_t buf = pbdrv_write_cmd_res_state({ + .state = PB_GS_IDLE, + }); + + ASSERT_NE(buf.data, nullptr); + ASSERT_GE(buf.size, 0); +} + TEST(pbdrv, write_cmd_req_set_state) { pbdrv_buf_t buf = pbdrv_write_cmd_req_set_state({ - .header = { .sender = 0xf0, }, .state = PB_GS_PLAYING, }); @@ -12,3 +60,13 @@ TEST(pbdrv, write_cmd_req_set_state) { ASSERT_GE(buf.size, 0); } +TEST(pbdrv, write_cmd_magic) { + pbdrv_buf_t buf = pbdrv_write_cmd_magic({ + .magic = pb_cmd_magic_msg, + ._magic_size = sizeof(pb_cmd_magic_msg), + }); + + ASSERT_NE(buf.data, nullptr); + ASSERT_GE(buf.size, 0); +} + -- cgit v1.2.3