summaryrefslogtreecommitdiff
path: root/xdelta3/testing/test.h
blob: 12f6b345e64bfcefb48495777d3572d1e2d4f9bc (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// -*- Mode: C++ -*-

extern "C" {
#define NOT_MAIN 1
#define REGRESSION_TEST 0
#include "../xdelta3.c"
}

#define CHECK_EQ(x,y) CHECK_OP(x,y,==)
#define CHECK_NE(x,y) CHECK_OP(x,y,!=)
#define CHECK_LT(x,y) CHECK_OP(x,y,<)
#define CHECK_GT(x,y) CHECK_OP(x,y,>)
#define CHECK_LE(x,y) CHECK_OP(x,y,<=)
#define CHECK_GE(x,y) CHECK_OP(x,y,>=)

#define CHECK_OP(x,y,OP) \
do {if (!((x) OP (y))) {			       \
  cerr << __FILE__ << ":" << __LINE__ << " Check failed: " << #x " " #OP " " #y << endl; \
  cerr << __FILE__ << ":" << __LINE__ << " Expected: " << x << endl; \
  cerr << __FILE__ << ":" << __LINE__ << " Actual: " << y << endl; \
  abort(); \
    } } while (false)

#define CHECK(x) \
  do {if (!(x)) {				       \
  cerr << __FILE__ << ":" << __LINE__ << " Check failed: " << #x << endl; \
  abort(); \
    } } while (false)

//#define VLOG(n) if ((n) >= debug_level) cerr
//static int debug_level;

#include <iostream>
using std::cerr;
using std::endl;

#include <map> 
using std::map;
using std::pair;

#include <list>
using std::list;

template <typename T, typename U>
pair<T, U> make_pair(const T& t, const U& u) {
  return pair<T, U>(t, u);
}

class Constants {
public:
  static const xoff_t BLOCK_SIZE = 1 << 15;
};

using std::min;

#include "segment.h"

#include "random.h"
using regtest::MTRandom;

#include "modify.h"
using regtest::Mutator;
using regtest::ChangeList;
using regtest::Change;
using regtest::ChangeListMutator;
using regtest::Modify1stByte;

#include "file.h"
using regtest::FileSpec;
using regtest::Block;
using regtest::BlockIterator;

#include "cmp.h"
using regtest::CmpDifferentBytes;

#include "sizes.h"
using regtest::SizeIterator;
using regtest::SmallSizes;