From f6f40266ba57ab2df99b897c375f85f0a8a97856 Mon Sep 17 00:00:00 2001 From: Levent Kaya Date: Wed, 5 Nov 2025 22:11:58 +0300 Subject: [feature] basic structure --- tests/CMakeLists.txt | 20 ++++++++++++++++++++ tests/test_logger.cpp | 15 +++++++++++++++ tests/test_main.cpp | 14 ++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/test_logger.cpp create mode 100644 tests/test_main.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..67baeda --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,20 @@ +# Unit tests for BoltDBG + +# Optionally enable sanitizers for test builds +if(BOLTDBG_ENABLE_ASAN) + add_compile_options(-fsanitize=address -fno-omit-frame-pointer) + add_link_options(-fsanitize=address) +endif() + +# Collect test sources +set(TEST_SOURCES + test_main.cpp + test_logger.cpp +) + +add_executable(boltdbg_tests ${TEST_SOURCES}) +target_include_directories(boltdbg_tests PRIVATE ${CMAKE_SOURCE_DIR}/include) +target_link_libraries(boltdbg_tests PRIVATE libboltdbg) + +# If using CTest (already enabled from top-level) +add_test(NAME boltdbg_tests COMMAND boltdbg_tests) diff --git a/tests/test_logger.cpp b/tests/test_logger.cpp new file mode 100644 index 0000000..536383b --- /dev/null +++ b/tests/test_logger.cpp @@ -0,0 +1,15 @@ +#include +//#include "../src/util/logger.h" + +void run_logger_tests(int &passed, int &failed) { + std::cout << "Running logger tests...\n"; + + try { + //log(LogLevel::Info, "Test info message"); + //log(LogLevel::Warn, "Test warning message"); + //log(LogLevel::Error, "Test error message"); + //passed++; + } catch (...) { + failed++; + } +} diff --git a/tests/test_main.cpp b/tests/test_main.cpp new file mode 100644 index 0000000..5b22560 --- /dev/null +++ b/tests/test_main.cpp @@ -0,0 +1,14 @@ +#include + +int main() { + std::cout << "[BoltDBG] Running tests...\n"; + int passed = 0, failed = 0; + + extern void run_logger_tests(int&, int&); + run_logger_tests(passed, failed); + + std::cout << "Tests passed: " << passed << "\n"; + std::cout << "Tests failed: " << failed << "\n"; + + return failed > 0 ? 1 : 0; +} -- cgit v1.2.3