Files
shadowsocks-libev/tests/test_helpers.hpp
T
Max Lv f90cfe9034 Add C++20 ownership and allocation core
Header-only primitives for the no-heap-after-startup design:
Result/Status, Region, ObjectPool with PoolPtr (std::unique_ptr with a
pool deleter), generation-checked Handle and asynchronous close support,
intrusive RefPtr, FixedBuffer, MonotonicArena, FixedHashMap and FixedLru,
IntrusiveList, and a bounded FixedHeap for third-party allocator hooks.

Unit tests cover each primitive (test_core_*). scripts/check_no_heap.py
rejects heap allocation in C++ sources under src/ and runs as a ctest.
clang-tidy now also analyses C++ sources and the core headers.
2026-10-14 12:51:47 +08:00

27 lines
1.2 KiB
C++

/* SPDX-License-Identifier: GPL-3.0-or-later */
#ifndef SS_TEST_HELPERS_HPP
#define SS_TEST_HELPERS_HPP
// Minimal harness for the C++ unit tests. Tests are built without
// exceptions, so a failed check reports its location and aborts.
#include <cstdio>
#include <cstdlib>
#define SS_CHECK(...) \
do { \
if (!(__VA_ARGS__)) { \
std::fprintf(stderr, "%s:%d: check failed: %s\n", __FILE__, \
__LINE__, #__VA_ARGS__); \
std::abort(); \
} \
} while (0)
#define SS_RUN(test) \
do { \
test(); \
std::printf("ok %s\n", #test); \
} while (0)
#endif