forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_helpers.cpp
More file actions
83 lines (63 loc) · 1.99 KB
/
Copy pathtest_helpers.cpp
File metadata and controls
83 lines (63 loc) · 1.99 KB
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
79
80
81
82
83
#include <utility>
#include "catch.hpp"
#include "helpers.hpp"
using itertest::SolidInt;
using itertest::IsIterator;
namespace {
class ValidIter {
private:
int i;
public:
ValidIter& operator++(); // prefix
ValidIter operator++(int); // postfix
bool operator==(const ValidIter&) const;
bool operator!=(const ValidIter&) const;
int operator*();
void* operator->();
};
}
TEST_CASE("IsIterator fails when missing prefix ++", "[helpers]") {
struct InvalidIter : ValidIter {
InvalidIter& operator++() = delete;
};
REQUIRE( !IsIterator<InvalidIter>::value );
}
TEST_CASE("IsIterator fails when missing postfix ++", "[helpers]") {
struct InvalidIter : ValidIter {
InvalidIter operator++(int) = delete;
};
REQUIRE( !IsIterator<InvalidIter>::value );
}
TEST_CASE("IsIterator fails when missing ==", "[helpers]") {
struct InvalidIter : ValidIter {
bool operator==(const InvalidIter&) const = delete;
};
REQUIRE( !IsIterator<InvalidIter>::value );
}
TEST_CASE("IsIterator fails when missing !=", "[helpers]") {
struct InvalidIter : ValidIter {
bool operator!=(const InvalidIter&) const = delete;
};
REQUIRE( !IsIterator<InvalidIter>::value );
}
TEST_CASE("IsIterator fails when missing *", "[helpers]") {
struct InvalidIter : ValidIter {
int operator*() = delete;
};
REQUIRE( !IsIterator<InvalidIter>::value );
}
TEST_CASE("IsIterator fails when missing copy-ctor", "[helpers]") {
struct InvalidIter : ValidIter {
InvalidIter(const InvalidIter&) = delete;
};
REQUIRE( !IsIterator<InvalidIter>::value );
}
TEST_CASE("IsIterator fails when missing copy assignment", "[helpers]") {
struct InvalidIter : ValidIter {
InvalidIter& operator=(const InvalidIter&) = delete;
};
REQUIRE( !IsIterator<InvalidIter>::value );
}
TEST_CASE("IsIterator passes a valid iterator", "[helpers]") {
REQUIRE( IsIterator<ValidIter>::value );
}