prepare v1.1.4
[awesomized/libmemcached] / test / lib / ReturnMatcher.hpp
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 #include "test/lib/common.hpp"
19
20 class ReturnMatcher : public Catch::MatcherBase<memcached_return_t> {
21 public:
22 explicit ReturnMatcher(memcached_st *memc_,
23 memcached_return_t expected_ = MEMCACHED_SUCCESS)
24 : memc{memc_}
25 , expected{expected_} {}
26
27 ReturnMatcher(const ReturnMatcher &) = default;
28
29 bool match(const memcached_return_t &arg) const override;
30 ReturnMatcher success();
31 ReturnMatcher operator()(memcached_return_t expected_);
32 ReturnMatcher &operator=(memcached_st *memc_);
33
34 protected:
35 string describe() const override;
36
37 private:
38 memcached_st *memc;
39 memcached_return_t expected{MEMCACHED_SUCCESS};
40 };
41
42 class LoneReturnMatcher {
43 public:
44 ReturnMatcher returns;
45 explicit LoneReturnMatcher(memcached_st *memc)
46 : returns{memc} {}
47 };