aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-14 17:23:22 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-14 17:23:22 +0200
commit15ee8bd8885c8b3d0b4650fe609c253780f04bdf (patch)
treedf952b8f62dce49283a8f3937771ccc572fc13ad /test
parentef162ca3445d9adb000d7dfd1b68b181ef958926 (diff)
WIP more puzzle bus driver code
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/pbdrv/msg.cpp21
2 files changed, 23 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9b1f40e..a01d2b0 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -4,6 +4,8 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+set(CMAKE_BUILD_TYPE Debug)
+
project(pbtest C CXX ASM)
add_executable(test
diff --git a/test/pbdrv/msg.cpp b/test/pbdrv/msg.cpp
index 320d6b3..38df8f4 100644
--- a/test/pbdrv/msg.cpp
+++ b/test/pbdrv/msg.cpp
@@ -28,3 +28,24 @@ TEST(pb_msg_rw, cmd_req_read) {
pb_msg_free(msg_read);
}
+TEST(pb_msg_rw, cmd_req_magic) {
+ pb_buf_t buf = pb_msg_write_req_magic();
+
+ ASSERT_NE(buf.data, nullptr);
+ ASSERT_GE(buf.size, 0);
+
+ pb_msg_t * msg_read = pb_msg_read(&buf);
+ pb_buf_free(&buf);
+
+ ASSERT_EQ(buf.data, nullptr);
+
+ EXPECT_EQ(msg_read->type, PB_CMD_REQ_MAGIC);
+ EXPECT_EQ(msg_read->sender, 0);
+ EXPECT_NE(msg_read->msg, nullptr);
+ pb_cmd_res_magic_t * magic = (pb_cmd_res_magic_t *) msg_read->msg;
+ EXPECT_EQ(magic->_magic_size, sizeof(pb_cmd_magic_req));
+ EXPECT_EQ(0, memcmp(pb_cmd_magic_req, magic->magic, magic->_magic_size));
+
+ pb_msg_free(msg_read);
+}
+