tests: be more elaborate about what was expected
[awesomized/libmemcached] / test / lib / ReturnMatcher.cpp
1 #include "ReturnMatcher.hpp"
2
3 bool ReturnMatcher::match(const memcached_return_t &arg) const {
4 if (arg != expected) {
5 if (expected == MEMCACHED_SUCCESS && arg == MEMCACHED_BUFFERED && memc) {
6 return memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS);
7 }
8 return false;
9 }
10 return true;
11 }
12
13 ReturnMatcher ReturnMatcher::success() {
14 return ReturnMatcher{memc};
15 }
16
17 ReturnMatcher ReturnMatcher::operator()(memcached_return_t expected_) {
18 return ReturnMatcher{memc, expected_};
19 }
20
21 ReturnMatcher &ReturnMatcher::operator=(memcached_st *memc_) {
22 memc = memc_;
23 return *this;
24 }
25
26 string ReturnMatcher::describe() const {
27 return "// but '" + to_string(expected) + "' was expected\n"
28 + "last error: " + memcached_last_error_message(memc);
29 }
30