From 4669644ccedb2c330336590babf0215ee5d303c6 Mon Sep 17 00:00:00 2001 From: ovizro Date: Thu, 28 Nov 2024 18:14:00 +0800 Subject: [PATCH] add a test case --- include/c_testcase.h | 2 +- include/dataqueue.hpp | 3 +-- include/extern_interface.h | 8 ++++++++ tests/test_queue.cpp | 9 +++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 tests/test_queue.cpp diff --git a/include/c_testcase.h b/include/c_testcase.h index 017245f..86926b0 100644 --- a/include/c_testcase.h +++ b/include/c_testcase.h @@ -164,7 +164,7 @@ int _add_test_case(const char* name, test_case func); int _set_interactive(interactive_func func); int _set_setup(context_func func); int _set_teardown(context_func func); -void __attribute__((noreturn)) test_case_abort(int exit_code); +[[noreturn]] void test_case_abort(int exit_code); #ifdef __cplusplus } diff --git a/include/dataqueue.hpp b/include/dataqueue.hpp index c742127..8c2a92a 100644 --- a/include/dataqueue.hpp +++ b/include/dataqueue.hpp @@ -8,8 +8,7 @@ template class DataQueue { public: - DataQueue(size_t init_size = 0) : m_Queue(init_size) - {} + DataQueue() = default; DataQueue(DataQueue&) = delete; void Push(T data) diff --git a/include/extern_interface.h b/include/extern_interface.h index a129e17..be2e6f7 100644 --- a/include/extern_interface.h +++ b/include/extern_interface.h @@ -12,6 +12,12 @@ #define ET_TYPE_ALARM 4 #define ET_TYPE_TELEMETRY_REQUEST 5 +#if defined(_MSC_VER) +#define EXTERN_INTERFACE_PUBLIC __declspec(dllexport) +#elif defined(__GNUC__) +#define EXTERN_INTERFACE_PUBLIC __attribute__ ((dllexport)) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -39,7 +45,9 @@ union PacketData typedef void (*et_callback_t)(uint32_t, size_t, union PacketData); +EXTERN_INTERFACE_PUBLIC void extern_interface_init(const char* config_path, et_callback_t cb); +EXTERN_INTERFACE_PUBLIC void extern_interface_send(uint32_t type, size_t len, union PacketData data); #ifdef __cplusplus diff --git a/tests/test_queue.cpp b/tests/test_queue.cpp new file mode 100644 index 0000000..ca32165 --- /dev/null +++ b/tests/test_queue.cpp @@ -0,0 +1,9 @@ +#include "c_testcase.h" +#include "dataqueue.hpp" + +TEST_CASE(init) { + DataQueue q; + assert(q.Empty()); + assert_eq(q.Size(), 0); + END_TEST; +}