start using a .clang-format code style
[m6w6/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(const memcached_st *memc_,
23 memcached_return_t expected_ = MEMCACHED_SUCCESS)
24 : memc{memc_}
25 , expected{expected_} {}
26
27 ReturnMatcher(const ReturnMatcher &) = default;
28
29 ReturnMatcher(ReturnMatcher &&rm);
30 ReturnMatcher &operator=(ReturnMatcher &&rm);
31
32 bool match(const memcached_return_t &arg) const override;
33 ReturnMatcher success();
34 ReturnMatcher operator()(memcached_return_t expected_);
35
36 protected:
37 string describe() const override;
38
39 private:
40 const memcached_st *memc;
41 memcached_return_t expected{MEMCACHED_SUCCESS};
42 };
43
44 class LoneReturnMatcher {
45 public:
46 ReturnMatcher returns;
47 explicit LoneReturnMatcher(const memcached_st *memc)
48 : returns{memc} {}
49 };