Mercurial > pub > dyncall > dyncall
comparison test/plain_c++/test_framework.h @ 0:3e629dc19168
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:24:28 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3e629dc19168 |
---|---|
1 /* | |
2 | |
3 Package: dyncall | |
4 Library: test | |
5 File: test/plain_c++/test_framework.h | |
6 Description: | |
7 License: | |
8 | |
9 Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>, | |
10 Tassilo Philipp <tphilipp@potion-studios.com> | |
11 | |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
26 | |
27 | |
28 // 2007-10-11 | |
29 | |
30 #ifndef TRUE | |
31 #define TRUE (1) | |
32 #endif | |
33 | |
34 #ifndef FALSE | |
35 #define FALSE (0) | |
36 #endif | |
37 | |
38 // Statement breaking into debugger (for various platforms). @@@add if defined, etc... | |
39 #ifdef _WIN32 | |
40 # ifdef _MSC_VER | |
41 # define DC_TEST_BREAK __debugbreak | |
42 # else | |
43 # include <windows.h> | |
44 # define DC_TEST_BREAK DebugBreak | |
45 # endif | |
46 #else | |
47 # define DC_TEST_BREAK | |
48 #endif | |
49 | |
50 // Test state - evaluates to false inside a test function if a test fails. | |
51 #define DC_TEST_STATE testFramework_state | |
52 | |
53 // Test functions defined by DC_DEFINE_TEST_FUNC_BEGIN and DC_DEFINE_TEST_FUNC_END pairs do come with | |
54 // a default parameter used to pass a path to them specifying where to find external data needed to | |
55 // run the tests (if desired). NULL by default. It can be queried by using DC_TEST_PATH. | |
56 #define DC_TEST_PATH testFramework_suitePath | |
57 | |
58 // Test a single expression - the expression must evaluate to true in order to succeed. | |
59 // #define DC_TEST(exp) { TEST_STATE = TEST_STATE && (exp); if(!TEST_STATE) DC_TEST_BREAK(); } | |
60 | |
61 #include <assert.h> | |
62 | |
63 #define DC_TEST(exp) assert(exp) | |
64 // { if (! (exp) ) DC_TEST_BREAK(); } | |
65 | |
66 // Macros used to define a test functions. | |
67 #define DC_DEFINE_TEST_FUNC_BEGIN(name) /*static */int name(/*const char* DC_TEST_PATH=NULL*/) { /*@@@ add logging*/ int TEST_STATE = TRUE; | |
68 #define DC_DEFINE_TEST_FUNC_END /*@@@ add logging*/ return TEST_STATE; } |