diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-14 18:49:03 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-14 18:49:03 +0200 |
commit | 33ff43ccd7c619f885b3dd4e9a2e0ffe7ed0875c (patch) | |
tree | d9a42ad176f6ea2094b75026b221f44bae45071a /test | |
parent | 959d43a0aeedcbc80c9bb2d4c99b4f5bd4e7b3d2 (diff) |
finish message send functions
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 3 | ||||
-rw-r--r-- | test/pbdrv/mod.c | 6 | ||||
-rw-r--r-- | test/pbdrv/msg.cpp | 20 |
3 files changed, 19 insertions, 10 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a01d2b0..30f3f77 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,6 +11,7 @@ project(pbtest C CXX ASM) add_executable(test # i2ctcp/main.cpp pbdrv/msg.cpp + pbdrv/mod.c ) add_subdirectory(lib/googletest) @@ -21,6 +22,6 @@ target_link_libraries(test gtest_main i2ctcp mpack - pbdrv + pbdrv-mod ) diff --git a/test/pbdrv/mod.c b/test/pbdrv/mod.c new file mode 100644 index 0000000..81e4ebf --- /dev/null +++ b/test/pbdrv/mod.c @@ -0,0 +1,6 @@ +#include "pb-mod.h" +#include "pb-types.h" + +const char * PB_MOD_NAME = "test"; +const i2c_addr_t PB_MOD_ADDR = 0x08; + diff --git a/test/pbdrv/msg.cpp b/test/pbdrv/msg.cpp index afc548e..d58d6f3 100644 --- a/test/pbdrv/msg.cpp +++ b/test/pbdrv/msg.cpp @@ -1,16 +1,18 @@ #include <gtest/gtest.h> #include "pb-msg.h" +#include "pb-send.h" +#include "pb-mod.h" TEST(pb_msg_rw, cmd_req_read) { - pb_cmd_prop_t content = { + pb_cmd_prop_t cmd = { .propid = 2, }; pb_msg_t msg_write = { .type = PB_CMD_PROP, .action = PB_ACTION_REQ, .sender = 0xff, - .msg = &content, + .cmd = &cmd, }; pb_buf_t buf = pb_msg_write(&msg_write); @@ -24,15 +26,15 @@ TEST(pb_msg_rw, cmd_req_read) { EXPECT_EQ(msg_write.type, msg_read->type); EXPECT_EQ(msg_write.sender, msg_read->sender); - EXPECT_NE(nullptr, msg_read->msg); - pb_cmd_prop_t * prop = (pb_cmd_prop_t *) msg_read->msg; - EXPECT_EQ(prop->propid, content.propid); + EXPECT_NE(nullptr, msg_read->cmd); + pb_cmd_prop_t * prop = (pb_cmd_prop_t *) msg_read->cmd; + EXPECT_EQ(prop->propid, cmd.propid); pb_msg_free(msg_read); } TEST(pb_msg_rw, cmd_req_magic) { - pb_buf_t buf = pb_msg_write_req_magic(); + pb_buf_t buf = pb_send_req_magic(); ASSERT_NE(buf.data, nullptr); ASSERT_GE(buf.size, 0); @@ -43,9 +45,9 @@ TEST(pb_msg_rw, cmd_req_magic) { ASSERT_EQ(buf.data, nullptr); EXPECT_EQ(msg_read->type, PB_CMD_MAGIC); - EXPECT_EQ(msg_read->sender, 0); - EXPECT_NE(msg_read->msg, nullptr); - pb_cmd_magic_t * magic = (pb_cmd_magic_t *) msg_read->msg; + EXPECT_EQ(msg_read->sender, PB_MOD_ADDR); + EXPECT_NE(msg_read->cmd, nullptr); + pb_cmd_magic_t * magic = (pb_cmd_magic_t *) msg_read->cmd; EXPECT_EQ(magic->_magic_size, sizeof(pb_cmd_magic_req)); EXPECT_EQ(0, memcmp(pb_cmd_magic_req, magic->magic, magic->_magic_size)); |