-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathtest.common.h
More file actions
45 lines (40 loc) · 1.88 KB
/
test.common.h
File metadata and controls
45 lines (40 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (c) 2022 Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
#include "common.h"
#define TEST_START() \
static int32_t failedTestCaseCount = 0;
#define TEST(value, expected) \
if (value == expected) \
{ \
PRINT(#value << " == " << #expected); \
} \
else \
{ \
failedTestCaseCount++; \
ERR(#value << " == " << value << " but != " \
<< #expected << " (expected)"); \
}
#define TEST_END() \
if (failedTestCaseCount != 0) \
{ \
ERR(failedTestCaseCount << " tests failed so far"); \
}
#define TEST_EXIT_CODE() failedTestCaseCount
#define TEST_REPORT(testName, functionCall) \
do \
{ \
auto result = functionCall; \
if (result == 0) \
{ \
SUCCESS(testName << " tests succeeded"); \
} \
else \
{ \
ERR(testName << " failed with exit code " << result); \
return result; \
} \
} while (false)