xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
Unit Tests

Running Tests

XaleDB includes a comprehensive test suite to ensure code quality and correctness. Tests cover all major components of the database engine.

Build and Run Tests

# Build the project including tests
cmake -B ./build
cmake --build ./build
# Run the test suite
./build/xale-db-tests

Test Structure

The test suite is organized by component:

  • Storage Tests: File management and storage engine functionality
    • FileManagerTests.h - Binary file operations
    • StorageEngineTests.h - Storage engine operations
  • Data Structure Tests: Core data structures
    • BPlusTreeTests.h - B+ tree indexing operations
  • Query Tests: Query parsing and tokenization
    • BasicTokenizerTests.h - SQL tokenization
    • BasicParserTests.h - SQL parsing
  • Execution Tests: Query execution components
    • TableManagerTests.h - Table management operations
    • BasicExecutorTests.h - SQL statement execution

Test Framework

Tests use a custom lightweight testing framework defined in TestsHelper.h:

  • Registration: Tests are automatically registered using the DECLARE_TEST macro
  • Execution: All tests run sequentially with pass/fail reporting
  • Output: Clear console output showing test results

Writing New Tests

To add a new test:

  1. Create a test header file in the appropriate subdirectory under tests/
  2. Include TestsHelper.h
  3. Define your test using the DECLARE_TEST macro:
#include "TestsHelper.h"
DECLARE_TEST(ComponentName, TestName) {
// Your test code here
return true; // or false if test fails
}
  1. Include your test header in tests/main.cpp

Test Configuration

During test execution:

  • Logger output is disabled to keep test output clean
  • A temporary test file (test-storage-file-unit-tests.bin) is created for storage tests
  • Tests are isolated and do not affect production data