interplane.Get Omega
Read in your language

cJSON

[Ported from github.com/DaveGamble/cJSON] Fix: heap-use-after-free in merge_patch when patch is subtree of target (#1065)

Brought by drakestapleton

branch master Branches Tags History

cJSON / tests / unity / extras / fixture / src / unity_fixture.h

83 lines · 3348 bytes Raw Blame History
1/* Copyright (c) 2010 James Grenning and Contributed to Unity Project
2 * ==========================================
3 * Unity Project - A Test Framework for C
4 * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
5 * [Released under MIT License. Please refer to license.txt for details]
6 * ========================================== */
7
8#ifndef UNITY_FIXTURE_H_
9#define UNITY_FIXTURE_H_
10
11#include "unity.h"
12#include "unity_internals.h"
13#include "unity_fixture_malloc_overrides.h"
14#include "unity_fixture_internals.h"
15
16int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
17
18
19#define TEST_GROUP(group)\
20 static const char* TEST_GROUP_##group = #group
21
22#define TEST_SETUP(group) void TEST_##group##_SETUP(void);\
23 void TEST_##group##_SETUP(void)
24
25#define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void);\
26 void TEST_##group##_TEAR_DOWN(void)
27
28
29#define TEST(group, name) \
30 void TEST_##group##_##name##_(void);\
31 void TEST_##group##_##name##_run(void);\
32 void TEST_##group##_##name##_run(void)\
33 {\
34 UnityTestRunner(TEST_##group##_SETUP,\
35 TEST_##group##_##name##_,\
36 TEST_##group##_TEAR_DOWN,\
37 "TEST(" #group ", " #name ")",\
38 TEST_GROUP_##group, #name,\
39 __FILE__, __LINE__);\
40 }\
41 void TEST_##group##_##name##_(void)
42
43#define IGNORE_TEST(group, name) \
44 void TEST_##group##_##name##_(void);\
45 void TEST_##group##_##name##_run(void);\
46 void TEST_##group##_##name##_run(void)\
47 {\
48 UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")", TEST_GROUP_##group, #name);\
49 }\
50 void TEST_##group##_##name##_(void)
51
52/* Call this for each test, insider the group runner */
53#define RUN_TEST_CASE(group, name) \
54 { void TEST_##group##_##name##_run(void);\
55 TEST_##group##_##name##_run(); }
56
57/* This goes at the bottom of each test file or in a separate c file */
58#define TEST_GROUP_RUNNER(group)\
59 void TEST_##group##_GROUP_RUNNER(void);\
60 void TEST_##group##_GROUP_RUNNER(void)
61
62/* Call this from main */
63#define RUN_TEST_GROUP(group)\
64 { void TEST_##group##_GROUP_RUNNER(void);\
65 TEST_##group##_GROUP_RUNNER(); }
66
67/* CppUTest Compatibility Macros */
68#ifndef UNITY_EXCLUDE_CPPUTEST_ASSERTS
69/* Sets a pointer and automatically restores it to its old value after teardown */
70#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&(ptr), (void*)(newPointerValue), __LINE__)
71#define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR((expected), (actual))
72#define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual))
73#define FAIL(message) TEST_FAIL_MESSAGE((message))
74#define CHECK(condition) TEST_ASSERT_TRUE((condition))
75#define LONGS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_INT((expected), (actual))
76#define STRCMP_EQUAL(expected, actual) TEST_ASSERT_EQUAL_STRING((expected), (actual))
77#define DOUBLES_EQUAL(expected, actual, delta) TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual))
78#endif
79
80/* You must compile with malloc replacement, as defined in unity_fixture_malloc_overrides.h */
81void UnityMalloc_MakeMallocFailAfterCount(int count);
82
83#endif /* UNITY_FIXTURE_H_ */