UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
test
unit_common.h
Go to the documentation of this file.
1
#ifndef TEST_UNIT_COMMON_H_7A471D89_C7E4_470A_A330_74F4BD85BBAC
2
#define TEST_UNIT_COMMON_H_7A471D89_C7E4_470A_A330_74F4BD85BBAC
3
4
#ifdef __cplusplus
5
#include <cinttypes>
6
#include <cstdio>
7
#include <iostream>
8
#else
9
#include <inttypes.h>
10
#include <stdio.h>
11
#endif
12
13
#define ASSERT(expr) \
14
if (!(expr)) { \
15
fprintf(stderr, "Assertion " #expr " failed!\n"); \
16
return -1; \
17
}
18
19
#ifdef __cplusplus
20
#define ASSERT_MESSAGE(msg, expr) \
21
if (!(expr)) { \
22
std::cerr << "Assertion " << #expr << " failed: " << (msg) \
23
<< "\n"; \
24
return -1; \
25
}
26
#else
27
#define ASSERT_MESSAGE(msg, expr) \
28
if (!(expr)) { \
29
fprintf(stderr, "Assertion " #expr " failed: %s\n", (msg)); \
30
return -1; \
31
}
32
#endif
33
34
#ifdef __cplusplus
35
#define ASSERT_EQUAL(expected, actual) \
36
if ((expected) != (actual)) { \
37
std::cerr << "Assertion failed - expected " << (expected) \
38
<< ", actual : " << (actual) << "\n"; \
39
return -1; \
40
}
41
#else
42
#define ASSERT_EQUAL(expected, actual) \
43
if ((expected) != (actual)) { \
44
fprintf(stderr, \
45
"Assertion failed - expected %" PRIdMAX \
46
", actual %" PRIdMAX "\n", \
47
(intmax_t) (expected), (intmax_t) (actulal)); \
48
return -1; \
49
}
50
#endif
51
52
#ifdef __cplusplus
53
#define ASSERT_EQUAL_MESSAGE(msg, expected, actual) \
54
if ((expected) != (actual)) { \
55
std::cerr << "Assertion failed - expected " << (expected) \
56
<< ", actual " << (actual) << ": " << (msg) << "\n"; \
57
return -1; \
58
}
59
#else
60
#define ASSERT_EQUAL_MESSAGE(msg, expected, actual) \
61
if ((expected) != (actual)) { \
62
fprintf(stderr, \
63
"Assertion failed - expected %" PRIdMAX \
64
", actual %" PRIdMAX ": %s\n", \
65
(intmax_t) (expected), (intmax_t) (actual), (msg)); \
66
return -1; \
67
}
68
#endif
69
70
#define ASSERT_GE_MESSAGE(msg, expected, actual) \
71
if ((actual) < (expected)) { \
72
fprintf(stderr, \
73
"Assertion failed - expected >=%" PRIdMAX \
74
", got %" PRIdMAX ": %s\n", \
75
(intmax_t) (expected), (intmax_t) (actual), (msg)); \
76
return -1; \
77
}
78
79
#define ASSERT_LE_MESSAGE(msg, expected, actual) \
80
if ((actual) > (expected)) { \
81
fprintf(stderr, \
82
"Assertion failed - expected >=%" PRIdMAX \
83
", got %" PRIdMAX ": %s\n", \
84
(intmax_t) (expected), (intmax_t) (actual), (msg)); \
85
return -1; \
86
}
87
88
#endif
// defined TEST_UNIT_COMMON_H_7A471D89_C7E4_470A_A330_74F4BD85BBAC
Generated on Wed Sep 25 2024 14:27:25 for UltraGrid by
1.12.0