FuncDoodle
Loading...
Searching...
No Matches
Test.h File Reference

Lightweight testing framework for FuncDoodle. More...

#include <atomic>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  FuncDoodle::TestResult
 Represents a single failed or recorded test assertion. More...
class  FuncDoodle::TestRegistry
 Global singleton collecting test scope results. More...
struct  FuncDoodle::TestRegistry::ScopeResult
class  FuncDoodle::TestScope
 RAII-style test container for grouping assertions. More...

Namespaces

namespace  FuncDoodle
 The FuncDoodle C++ namespace.

Macros

#define CURRENT_FUNC   __func__
#define TEST_SCOPE(name)
 Starts a named RAII test scope.
#define CHECK(cond, msg)
 Records whether a condition is true.
#define CHECK_EQ(a, b, msg)
 Records whether two expressions are equal.
#define CHECK_NE(a, b, msg)
 Records whether two expressions are not equal.
#define CHECK_LT(a, b, msg)
 Records whether the left expression is less than the right.
#define CHECK_LE(a, b, msg)
 Records whether the left expression is less than or equal to the right.
#define CHECK_GT(a, b, msg)
 Records whether the left expression is greater than the right.
#define CHECK_GE(a, b, msg)
 Records whether the left expression is greater than or equal to the right.
#define CHECK_NULL(ptr, msg)
 Records whether a pointer is null.
#define CHECK_NOT_NULL(ptr, msg)
 Records whether a pointer is non-null.

Functions

std::string FuncDoodle::Repeat (std::string_view s, size_t n)
 Repeats a string N times.

Detailed Description

Lightweight testing framework for FuncDoodle.

This file implements a minimal unit testing system used for both:

  • Standard build tests (via FUNCDOODLE_BUILD_TESTS)
  • Optional ImGui-based test integration (via FUNCDOODLE_BUILD_IMTESTS)

Features:

  • Test scopes with automatic reporting
  • Assertions via CHECK macros
  • Summary statistics (pass/fail/percentage)
  • Optional ImGui test engine integration

The framework is designed to be simple, header-only, and zero-dependency aside from the optional ImGui test engine.

Macro Definition Documentation

◆ CHECK

#define CHECK ( cond,
msg )
Value:
_test_scope.Check(cond, #cond, msg)

Records whether a condition is true.

◆ CHECK_EQ

#define CHECK_EQ ( a,
b,
msg )
Value:
_test_scope.Check((a) == (b), #a " == " #b, msg)

Records whether two expressions are equal.

◆ CHECK_GE

#define CHECK_GE ( a,
b,
msg )
Value:
_test_scope.Check((a) >= (b), #a " >= " #b, msg)

Records whether the left expression is greater than or equal to the right.

◆ CHECK_GT

#define CHECK_GT ( a,
b,
msg )
Value:
_test_scope.Check((a) > (b), #a " > " #b, msg)

Records whether the left expression is greater than the right.

◆ CHECK_LE

#define CHECK_LE ( a,
b,
msg )
Value:
_test_scope.Check((a) <= (b), #a " <= " #b, msg)

Records whether the left expression is less than or equal to the right.

◆ CHECK_LT

#define CHECK_LT ( a,
b,
msg )
Value:
_test_scope.Check((a) < (b), #a " < " #b, msg)

Records whether the left expression is less than the right.

◆ CHECK_NE

#define CHECK_NE ( a,
b,
msg )
Value:
_test_scope.Check((a) != (b), #a " != " #b, msg)

Records whether two expressions are not equal.

◆ CHECK_NOT_NULL

#define CHECK_NOT_NULL ( ptr,
msg )
Value:
_test_scope.Check((ptr) != nullptr, #ptr " != nullptr", msg)

Records whether a pointer is non-null.

◆ CHECK_NULL

#define CHECK_NULL ( ptr,
msg )
Value:
_test_scope.Check((ptr) == nullptr, #ptr " == nullptr", msg)

Records whether a pointer is null.

◆ CURRENT_FUNC

#define CURRENT_FUNC   __func__

◆ TEST_SCOPE

#define TEST_SCOPE ( name)
Value:
FuncDoodle::TestScope _test_scope(name)
RAII-style test container for grouping assertions.
Definition Test.h:177

Starts a named RAII test scope.