add a test case

This commit is contained in:
ovizro 2024-11-28 18:14:00 +08:00
parent 9bf7306aa2
commit 4669644cce
4 changed files with 19 additions and 3 deletions

View File

@ -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
}

View File

@ -8,8 +8,7 @@
template <typename T>
class DataQueue {
public:
DataQueue(size_t init_size = 0) : m_Queue(init_size)
{}
DataQueue() = default;
DataQueue(DataQueue&) = delete;
void Push(T data)

View File

@ -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

9
tests/test_queue.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "c_testcase.h"
#include "dataqueue.hpp"
TEST_CASE(init) {
DataQueue<int> q;
assert(q.Empty());
assert_eq(q.Size(), 0);
END_TEST;
}