]> git.proxmox.com Git - ceph.git/blob - ceph/src/s3select/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / s3select / rapidjson / thirdparty / gtest / googletest / include / gtest / internal / gtest-param-util-generated.h.pump
1 $$ -*- mode: c++; -*-
2 $var n = 50 $$ Maximum length of Values arguments we want to support.
3 $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
4 // Copyright 2008 Google Inc.
5 // All Rights Reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
9 // met:
10 //
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
16 // distribution.
17 // * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
33 // Author: vladl@google.com (Vlad Losev)
34
35 // Type and function utilities for implementing parameterized tests.
36 // This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
37 //
38 // Currently Google Test supports at most $n arguments in Values,
39 // and at most $maxtuple arguments in Combine. Please contact
40 // googletestframework@googlegroups.com if you need more.
41 // Please note that the number of arguments to Combine is limited
42 // by the maximum arity of the implementation of tuple which is
43 // currently set at $maxtuple.
44
45 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
46 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
47
48 #include "gtest/internal/gtest-param-util.h"
49 #include "gtest/internal/gtest-port.h"
50
51 namespace testing {
52
53 // Forward declarations of ValuesIn(), which is implemented in
54 // include/gtest/gtest-param-test.h.
55 template <typename ForwardIterator>
56 internal::ParamGenerator<
57 typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
58 ValuesIn(ForwardIterator begin, ForwardIterator end);
59
60 template <typename T, size_t N>
61 internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
62
63 template <class Container>
64 internal::ParamGenerator<typename Container::value_type> ValuesIn(
65 const Container& container);
66
67 namespace internal {
68
69 // Used in the Values() function to provide polymorphic capabilities.
70 $range i 1..n
71 $for i [[
72 $range j 1..i
73
74 template <$for j, [[typename T$j]]>
75 class ValueArray$i {
76 public:
77 $if i==1 [[explicit ]]ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {}
78
79 template <typename T>
80 operator ParamGenerator<T>() const {
81 const T array[] = {$for j, [[static_cast<T>(v$(j)_)]]};
82 return ValuesIn(array);
83 }
84
85 private:
86 // No implementation - assignment is unsupported.
87 void operator=(const ValueArray$i& other);
88
89 $for j [[
90
91 const T$j v$(j)_;
92 ]]
93
94 };
95
96 ]]
97
98 # if GTEST_HAS_COMBINE
99 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
100 //
101 // Generates values from the Cartesian product of values produced
102 // by the argument generators.
103 //
104 $range i 2..maxtuple
105 $for i [[
106 $range j 1..i
107 $range k 2..i
108
109 template <$for j, [[typename T$j]]>
110 class CartesianProductGenerator$i
111 : public ParamGeneratorInterface< ::testing::tuple<$for j, [[T$j]]> > {
112 public:
113 typedef ::testing::tuple<$for j, [[T$j]]> ParamType;
114
115 CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])
116 : $for j, [[g$(j)_(g$j)]] {}
117 virtual ~CartesianProductGenerator$i() {}
118
119 virtual ParamIteratorInterface<ParamType>* Begin() const {
120 return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);
121 }
122 virtual ParamIteratorInterface<ParamType>* End() const {
123 return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);
124 }
125
126 private:
127 class Iterator : public ParamIteratorInterface<ParamType> {
128 public:
129 Iterator(const ParamGeneratorInterface<ParamType>* base, $for j, [[
130
131 const ParamGenerator<T$j>& g$j,
132 const typename ParamGenerator<T$j>::iterator& current$(j)]])
133 : base_(base),
134 $for j, [[
135
136 begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j)
137 ]] {
138 ComputeCurrentValue();
139 }
140 virtual ~Iterator() {}
141
142 virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
143 return base_;
144 }
145 // Advance should not be called on beyond-of-range iterators
146 // so no component iterators must be beyond end of range, either.
147 virtual void Advance() {
148 assert(!AtEnd());
149 ++current$(i)_;
150
151 $for k [[
152 if (current$(i+2-k)_ == end$(i+2-k)_) {
153 current$(i+2-k)_ = begin$(i+2-k)_;
154 ++current$(i+2-k-1)_;
155 }
156
157 ]]
158 ComputeCurrentValue();
159 }
160 virtual ParamIteratorInterface<ParamType>* Clone() const {
161 return new Iterator(*this);
162 }
163 virtual const ParamType* Current() const { return current_value_.get(); }
164 virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
165 // Having the same base generator guarantees that the other
166 // iterator is of the same type and we can downcast.
167 GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
168 << "The program attempted to compare iterators "
169 << "from different generators." << std::endl;
170 const Iterator* typed_other =
171 CheckedDowncastToActualType<const Iterator>(&other);
172 // We must report iterators equal if they both point beyond their
173 // respective ranges. That can happen in a variety of fashions,
174 // so we have to consult AtEnd().
175 return (AtEnd() && typed_other->AtEnd()) ||
176 ($for j && [[
177
178 current$(j)_ == typed_other->current$(j)_
179 ]]);
180 }
181
182 private:
183 Iterator(const Iterator& other)
184 : base_(other.base_), $for j, [[
185
186 begin$(j)_(other.begin$(j)_),
187 end$(j)_(other.end$(j)_),
188 current$(j)_(other.current$(j)_)
189 ]] {
190 ComputeCurrentValue();
191 }
192
193 void ComputeCurrentValue() {
194 if (!AtEnd())
195 current_value_.reset(new ParamType($for j, [[*current$(j)_]]));
196 }
197 bool AtEnd() const {
198 // We must report iterator past the end of the range when either of the
199 // component iterators has reached the end of its range.
200 return
201 $for j || [[
202
203 current$(j)_ == end$(j)_
204 ]];
205 }
206
207 // No implementation - assignment is unsupported.
208 void operator=(const Iterator& other);
209
210 const ParamGeneratorInterface<ParamType>* const base_;
211 // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
212 // current[i]_ is the actual traversing iterator.
213 $for j [[
214
215 const typename ParamGenerator<T$j>::iterator begin$(j)_;
216 const typename ParamGenerator<T$j>::iterator end$(j)_;
217 typename ParamGenerator<T$j>::iterator current$(j)_;
218 ]]
219
220 linked_ptr<ParamType> current_value_;
221 }; // class CartesianProductGenerator$i::Iterator
222
223 // No implementation - assignment is unsupported.
224 void operator=(const CartesianProductGenerator$i& other);
225
226
227 $for j [[
228 const ParamGenerator<T$j> g$(j)_;
229
230 ]]
231 }; // class CartesianProductGenerator$i
232
233
234 ]]
235
236 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
237 //
238 // Helper classes providing Combine() with polymorphic features. They allow
239 // casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
240 // convertible to U.
241 //
242 $range i 2..maxtuple
243 $for i [[
244 $range j 1..i
245
246 template <$for j, [[class Generator$j]]>
247 class CartesianProductHolder$i {
248 public:
249 CartesianProductHolder$i($for j, [[const Generator$j& g$j]])
250 : $for j, [[g$(j)_(g$j)]] {}
251 template <$for j, [[typename T$j]]>
252 operator ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >() const {
253 return ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >(
254 new CartesianProductGenerator$i<$for j, [[T$j]]>(
255 $for j,[[
256
257 static_cast<ParamGenerator<T$j> >(g$(j)_)
258 ]]));
259 }
260
261 private:
262 // No implementation - assignment is unsupported.
263 void operator=(const CartesianProductHolder$i& other);
264
265
266 $for j [[
267 const Generator$j g$(j)_;
268
269 ]]
270 }; // class CartesianProductHolder$i
271
272 ]]
273
274 # endif // GTEST_HAS_COMBINE
275
276 } // namespace internal
277 } // namespace testing
278
279 #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_