Some more tests (minor)
[gnash.git] / testsuite / check.h
blob46d7c061e3af829fdbd5650609a88aa766c2c006
1 #ifndef _CHECK_H_
2 #define _CHECK_H_
4 #ifdef HAVE_CONFIG_H
5 #include "gnashconfig.h"
6 #endif
8 #include <sstream>
9 #include <iostream>
10 #include <string>
12 #define HAVE_DEJAGNU_H 1 // we ship our own now...
13 #ifdef HAVE_DEJAGNU_H
14 #include "dejagnu.h"
16 #define info(x) note x
18 #else
19 //#warning "You should install DejaGnu! Using stubs for pass/fail/xpass/xfail..."
20 class TestState
22 public:
23 void pass(std::string s) { std::cout << "PASSED: " << s << std::endl; };
24 void xpass(std::string s) { std::cout << "XPASSED: " << s << std::endl; };
25 void fail(std::string s) { std::cout << "FAILED: " << s << std::endl; };
26 void xfail(std::string s) { std::cout << "XFAILED: " << s << std::endl; };
27 void unresolved(std::string s) { std::cout << "UNRESOLVED: " << s << std::endl; };
30 #define info(x) { printf("NOTE: "); printf x; putchar('\n'); }
32 #endif
34 TestState _runtest;
36 #define check_equals_label(label, expr, expected) \
37 { \
38 std::stringstream ss; \
39 if ( ! label.empty() ) ss << label << ": "; \
40 if ( expr == expected ) \
41 { \
42 ss << #expr << " == " << expected; \
43 ss << " [" << __FILE__ << ":" << __LINE__ << "]"; \
44 _runtest.pass(ss.str().c_str()); \
45 } \
46 else \
47 { \
48 ss << #expr << " == '" << expr << "' (expected: " \
49 << expected << ")"; \
50 ss << " [" << __FILE__ << ":" << __LINE__ << "]"; \
51 _runtest.fail(ss.str().c_str()); \
52 } \
55 #define xcheck_equals_label(label, expr, expected) \
56 { \
57 std::stringstream ss; \
58 if ( label != "" ) ss << label << ": "; \
59 if ( expr == expected ) \
60 { \
61 ss << #expr << " == " << expected; \
62 ss << " [" << __FILE__ << ":" << __LINE__ << "]"; \
63 _runtest.xpass(ss.str().c_str()); \
64 } \
65 else \
66 { \
67 ss << #expr << " == '" << expr << "' (expected: " \
68 << expected << ")"; \
69 ss << " [" << __FILE__ << ":" << __LINE__ << "]"; \
70 _runtest.xfail(ss.str().c_str()); \
71 } \
74 #define check_equals(expr, expected) check_equals_label(std::string(), expr, expected)
76 #define xcheck_equals(expr, expected) xcheck_equals_label(std::string(), expr, expected)
78 #define check(expr) \
79 { \
80 std::stringstream ss; \
81 ss << #expr; \
82 ss << " [" << __FILE__ << ":" << __LINE__ << "]"; \
83 if ( expr ) { \
84 _runtest.pass(ss.str().c_str()); \
85 } else { \
86 _runtest.fail(ss.str().c_str()); \
87 } \
90 #define xcheck(expr) \
91 { \
92 std::stringstream ss; \
93 ss << #expr; \
94 ss << " [" << __FILE__ << ":" << __LINE__ << "]"; \
95 if ( expr ) { \
96 _runtest.xpass(ss.str().c_str()); \
97 } else { \
98 _runtest.xfail(ss.str().c_str()); \
99 } \
102 #endif // _CHECK_H_