StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
test_handlers.h
1#pragma once
2
3#include <filesystem>
4#include <iostream>
5
6#define RETURN_TEST(fn_name, fn_result) { \
7 if (fn_result != 0) { \
8 std::cerr << "Test " << fn_name << " FAILED!" << std::endl; \
9 } \
10 return fn_result; \
11}
12
13#define CurrentFileDirectory std::filesystem::path(__FILE__).parent_path()
14
15#define ASSERT_EQUAL(fn_name, expected, actual) { \
16 if ((expected) != (actual)) { \
17 std::cerr << fn_name << ": Assertion failed at " << __FILE__ << ":" << __LINE__ << ": expected \"" << (expected) << "\", got \"" << (actual) << "\"" << std::endl; \
18 return 1; \
19 } \
20}
21
22#define ASSERT_NOT_EQUAL(fn_name, expected, actual) { \
23 if ((expected) == (actual)) { \
24 std::cerr << fn_name << ": Assertion failed at " << __FILE__ << ":" << __LINE__ << ": expected \"" << (expected) << "\", got \"" << (actual) << "\"" << std::endl; \
25 return 1; \
26 } \
27}
28
29#define ASSERT_FALSE(fn_name, condition) { \
30 if ((condition)) { \
31 std::cerr << fn_name << ": Assertion failed at " << __FILE__ << ":" << __LINE__ << ": condition is true, expected false" << std::endl; \
32 return 1; \
33 } \
34}
35
36#define ASSERT_TRUE(fn_name, condition) { \
37 if (!(condition)) { \
38 std::cerr << fn_name << ": Assertion failed at " << __FILE__ << ":" << __LINE__ << ": condition is false, expected true" << std::endl; \
39 return 1; \
40 } \
41}