diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2008-06-30 05:15:05 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2008-06-30 05:15:05 +0000 |
commit | 9e896b470f5a4550a7fbbdc515db08b0249f5950 (patch) | |
tree | 8f2ea4d701f554a578a7d7e441f98e1f77425e9a /xdelta3/testing/test.h | |
parent | e127914b71638072798f7c02e93caf9377ba7385 (diff) |
A test is taking shape...
Diffstat (limited to 'xdelta3/testing/test.h')
-rw-r--r-- | xdelta3/testing/test.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/xdelta3/testing/test.h b/xdelta3/testing/test.h new file mode 100644 index 0000000..dcec6d9 --- /dev/null +++ b/xdelta3/testing/test.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* -*- Mode: C++ -*- */ | ||
2 | |||
3 | extern "C" { | ||
4 | #define NOT_MAIN 1 | ||
5 | #define REGRESSION_TEST 0 | ||
6 | #include "../xdelta3.c" | ||
7 | } | ||
8 | |||
9 | #define CHECK_EQ(x,y) CHECK_OP(x,y,==) | ||
10 | #define CHECK_LT(x,y) CHECK_OP(x,y,<) | ||
11 | #define CHECK_GT(x,y) CHECK_OP(x,y,>) | ||
12 | #define CHECK_LE(x,y) CHECK_OP(x,y,<=) | ||
13 | #define CHECK_GE(x,y) CHECK_OP(x,y,>=) | ||
14 | |||
15 | #define CHECK_OP(x,y,OP) \ | ||
16 | do {if (!((x) OP (y))) { \ | ||
17 | cerr << "Check failed: " << #x " " #OP " " #y << endl; \ | ||
18 | cerr << "Expected: " << x << endl; \ | ||
19 | cerr << "Actual: " << y << endl; \ | ||
20 | abort(); \ | ||
21 | } } while (false) | ||
22 | |||
23 | #define CHECK(x) \ | ||
24 | do {if (!(x)) { \ | ||
25 | cerr << "Check failed: " << #x << endl; \ | ||
26 | abort(); \ | ||
27 | } } while (false) | ||
28 | |||
29 | #include <iostream> | ||
30 | using std::cerr; | ||
31 | using std::endl; | ||
32 | |||
33 | #include <map> | ||
34 | using std::map; | ||
35 | using std::pair; | ||
36 | |||
37 | template <typename T, typename U> | ||
38 | pair<T, U> make_pair(const T& t, const U& u) { | ||
39 | return pair<T, U>(t, u); | ||
40 | } | ||
41 | |||
42 | class Constants { | ||
43 | public: | ||
44 | static const xoff_t BLOCK_SIZE = 1 << 14; | ||
45 | }; | ||
46 | |||
47 | using std::min; | ||
48 | |||
49 | #include "random.h" | ||
50 | using regtest::MTRandom; | ||
51 | |||
52 | #include "file.h" | ||
53 | using regtest::FileSpec; | ||
54 | |||
55 | #include "modify.h" | ||
56 | using regtest::Modify1stByte; | ||
57 | |||
58 | #include "cmp.h" | ||
59 | using regtest::CmpDifferentBytes; | ||