OTest2
A C++ testing framework
comparisonslexi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Ondrej Starek
3  *
4  * This file is part of OTest2
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OTest2_INCLUDE_OTEST2_COMPARISONSLEXI_H_
21 #define OTest2_INCLUDE_OTEST2_COMPARISONSLEXI_H_
22 
23 #include <otest2/comparisons.h>
24 #include <otest2/typetraits.h>
25 
26 namespace OTest2 {
27 
31 template<typename A_, typename B_>
32 class LexiLess {
33  private:
34  Less<A_, B_> less;
35  Greater<A_, B_> greater;
36 
37  public:
39  typename TypeTrait<A_>::BestArg a_,
40  typename TypeTrait<B_>::BestArg b_) const {
41  if(less(a_, b_))
42  return -1;
43  if(greater(a_, b_))
44  return 1;
45  return 0;
46  }
47 
48  bool checkRests(
49  bool a_ends_,
50  bool b_ends_) const {
51  return a_ends_ && !b_ends_;
52  }
53 };
54 
58 template<typename A_, typename B_>
60  private:
61  Less<A_, B_> less;
62  Greater<A_, B_> greater;
63 
64  public:
66  typename TypeTrait<A_>::BestArg a_,
67  typename TypeTrait<B_>::BestArg b_) const {
68  if(less(a_, b_))
69  return -1;
70  if(greater(a_, b_))
71  return 1;
72  return 0;
73  }
74 
75  bool checkRests(
76  bool a_ends_,
77  bool b_ends_) const {
78  return a_ends_;
79  }
80 };
81 
85 template<typename A_, typename B_>
86 class LexiGreater {
87  private:
88  Less<A_, B_> less;
89  Greater<A_, B_> greater;
90 
91  public:
93  typename TypeTrait<A_>::BestArg a_,
94  typename TypeTrait<B_>::BestArg b_) const {
95  if(less(a_, b_))
96  return 1;
97  if(greater(a_, b_))
98  return -1;
99  return 0;
100  }
101 
103  bool a_ends_,
104  bool b_ends_) const {
105  return !a_ends_ && b_ends_;
106  }
107 };
108 
112 template<typename A_, typename B_>
114  private:
115  Less<A_, B_> less;
116  Greater<A_, B_> greater;
117 
118  public:
120  typename TypeTrait<A_>::BestArg a_,
121  typename TypeTrait<B_>::BestArg b_) const {
122  if(less(a_, b_))
123  return 1;
124  if(greater(a_, b_))
125  return -1;
126  return 0;
127  }
128 
130  bool a_ends_,
131  bool b_ends_) const {
132  return b_ends_;
133  }
134 };
135 
136 } /* -- namespace OTest2 */
137 
138 #endif /* -- OTest2_INCLUDE_OTEST2_COMPARISONSLEXI_H_ */
OTest2::LexiLessOrEqual::checkItems
int checkItems(typename TypeTrait< A_ >::BestArg a_, typename TypeTrait< B_ >::BestArg b_) const
Definition: comparisonslexi.h:65
OTest2::LexiGreater::checkRests
bool checkRests(bool a_ends_, bool b_ends_) const
Definition: comparisonslexi.h:102
OTest2::LexiGreater::checkItems
int checkItems(typename TypeTrait< A_ >::BestArg a_, typename TypeTrait< B_ >::BestArg b_) const
Definition: comparisonslexi.h:92
OTest2::TypeTrait::BestArg
Private::SelectArgType< Type_, std::is_scalar< Type_ >::value >::Value BestArg
Definition: typetraits.h:49
typetraits.h
OTest2::LexiLess::checkRests
bool checkRests(bool a_ends_, bool b_ends_) const
Definition: comparisonslexi.h:48
OTest2::LexiLess
the '<' operator for lexicographical assertions
Definition: comparisonslexi.h:32
OTest2::Less
Definition: comparisons.h:86
OTest2::LexiGreaterOrEqual
the '>=' operator for lexicographical assertions
Definition: comparisonslexi.h:113
OTest2::LexiLessOrEqual
the '<=' operator for lexicographical assertions
Definition: comparisonslexi.h:59
OTest2::LexiGreater
the '>' operator for lexicographical assertions
Definition: comparisonslexi.h:86
OTest2
Definition: assertbean.h:25
comparisons.h
OTest2::LexiLess::checkItems
int checkItems(typename TypeTrait< A_ >::BestArg a_, typename TypeTrait< B_ >::BestArg b_) const
Definition: comparisonslexi.h:38
OTest2::LexiLessOrEqual::checkRests
bool checkRests(bool a_ends_, bool b_ends_) const
Definition: comparisonslexi.h:75
OTest2::LexiGreaterOrEqual::checkRests
bool checkRests(bool a_ends_, bool b_ends_) const
Definition: comparisonslexi.h:129
OTest2::Greater
Definition: comparisons.h:122
OTest2::LexiGreaterOrEqual::checkItems
int checkItems(typename TypeTrait< A_ >::BestArg a_, typename TypeTrait< B_ >::BestArg b_) const
Definition: comparisonslexi.h:119