/
BeGreaterThan.h
62 lines (49 loc) · 1.79 KB
/
BeGreaterThan.h
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
#import <Foundation/Foundation.h>
#import "Base.h"
namespace Cedar { namespace Matchers {
template<typename T>
class BeGreaterThan : public Base<> {
private:
BeGreaterThan<T> & operator=(const BeGreaterThan<T> &);
public:
explicit BeGreaterThan(const T & expectedValue);
~BeGreaterThan();
// Allow default copy ctor.
template<typename U>
bool matches(const U &) const;
protected:
virtual NSString * failure_message_end() const;
private:
const T & expectedValue_;
};
template<typename T>
BeGreaterThan<T> be_greater_than(const T & expectedValue) {
return BeGreaterThan<T>(expectedValue);
}
template<typename T>
BeGreaterThan<T>::BeGreaterThan(const T & expectedValue)
: Base<>(), expectedValue_(expectedValue) {
}
template<typename T>
BeGreaterThan<T>::~BeGreaterThan() {
}
template<typename T>
/*virtual*/ NSString * BeGreaterThan<T>::failure_message_end() const {
NSString * expectedValueString = Stringifiers::string_for(expectedValue_);
return [NSString stringWithFormat:@"be greater than <%@>", expectedValueString];
}
template<typename T> template<typename U>
bool BeGreaterThan<T>::matches(const U & actualValue) const {
return Comparators::compare_greater_than(actualValue, expectedValue_);
}
#pragma mark operators
template<typename T, typename U>
bool operator>(const ActualValue<T> & actualValue, const U & expectedValue) {
return actualValue.to > expectedValue;
}
template<typename T, typename U>
bool operator>(const ActualValueMatchProxy<T> & actualValueMatchProxy, const U & expectedValue) {
actualValueMatchProxy(be_greater_than(expectedValue));
return true;
}
}}