OpenCores
URL https://opencores.org/ocsvn/s80186/s80186/trunk

Subversion Repositories s80186

[/] [s80186/] [trunk/] [vendor/] [googletest/] [googletest/] [include/] [gtest/] [internal/] [gtest-param-util-generated.h.pump] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
$$ -*- 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
// scripts/fuse_gtest.py depends on gtest's own header being #included
49
// *unconditionally*.  Therefore these #includes cannot be moved
50
// inside #if GTEST_HAS_PARAM_TEST.
51
#include "gtest/internal/gtest-param-util.h"
52
#include "gtest/internal/gtest-port.h"
53
 
54
#if GTEST_HAS_PARAM_TEST
55
 
56
namespace testing {
57
 
58
// Forward declarations of ValuesIn(), which is implemented in
59
// include/gtest/gtest-param-test.h.
60
template 
61
internal::ParamGenerator<
62
  typename ::testing::internal::IteratorTraits::value_type>
63
ValuesIn(ForwardIterator begin, ForwardIterator end);
64
 
65
template 
66
internal::ParamGenerator ValuesIn(const T (&array)[N]);
67
 
68
template 
69
internal::ParamGenerator ValuesIn(
70
    const Container& container);
71
 
72
namespace internal {
73
 
74
// Used in the Values() function to provide polymorphic capabilities.
75
$range i 1..n
76
$for i [[
77
$range j 1..i
78
 
79
template <$for j, [[typename T$j]]>
80
class ValueArray$i {
81
 public:
82
  $if i==1 [[explicit ]]ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {}
83
 
84
  template 
85
  operator ParamGenerator() const {
86
    const T array[] = {$for j, [[static_cast(v$(j)_)]]};
87
    return ValuesIn(array);
88
  }
89
 
90
 private:
91
  // No implementation - assignment is unsupported.
92
  void operator=(const ValueArray$i& other);
93
 
94
$for j [[
95
 
96
  const T$j v$(j)_;
97
]]
98
 
99
};
100
 
101
]]
102
 
103
# if GTEST_HAS_COMBINE
104
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
105
//
106
// Generates values from the Cartesian product of values produced
107
// by the argument generators.
108
//
109
$range i 2..maxtuple
110
$for i [[
111
$range j 1..i
112
$range k 2..i
113
 
114
template <$for j, [[typename T$j]]>
115
class CartesianProductGenerator$i
116
    : public ParamGeneratorInterface< ::testing::tuple<$for j, [[T$j]]> > {
117
 public:
118
  typedef ::testing::tuple<$for j, [[T$j]]> ParamType;
119
 
120
  CartesianProductGenerator$i($for j, [[const ParamGenerator& g$j]])
121
      : $for j, [[g$(j)_(g$j)]] {}
122
  virtual ~CartesianProductGenerator$i() {}
123
 
124
  virtual ParamIteratorInterface* Begin() const {
125
    return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);
126
  }
127
  virtual ParamIteratorInterface* End() const {
128
    return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);
129
  }
130
 
131
 private:
132
  class Iterator : public ParamIteratorInterface {
133
   public:
134
    Iterator(const ParamGeneratorInterface* base, $for j, [[
135
 
136
      const ParamGenerator& g$j,
137
      const typename ParamGenerator::iterator& current$(j)]])
138
        : base_(base),
139
$for j, [[
140
 
141
          begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j)
142
]]    {
143
      ComputeCurrentValue();
144
    }
145
    virtual ~Iterator() {}
146
 
147
    virtual const ParamGeneratorInterface* BaseGenerator() const {
148
      return base_;
149
    }
150
    // Advance should not be called on beyond-of-range iterators
151
    // so no component iterators must be beyond end of range, either.
152
    virtual void Advance() {
153
      assert(!AtEnd());
154
      ++current$(i)_;
155
 
156
$for k [[
157
      if (current$(i+2-k)_ == end$(i+2-k)_) {
158
        current$(i+2-k)_ = begin$(i+2-k)_;
159
        ++current$(i+2-k-1)_;
160
      }
161
 
162
]]
163
      ComputeCurrentValue();
164
    }
165
    virtual ParamIteratorInterface* Clone() const {
166
      return new Iterator(*this);
167
    }
168
    virtual const ParamType* Current() const { return ¤t_value_; }
169
    virtual bool Equals(const ParamIteratorInterface& other) const {
170
      // Having the same base generator guarantees that the other
171
      // iterator is of the same type and we can downcast.
172
      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
173
          << "The program attempted to compare iterators "
174
          << "from different generators." << std::endl;
175
      const Iterator* typed_other =
176
          CheckedDowncastToActualType(&other);
177
      // We must report iterators equal if they both point beyond their
178
      // respective ranges. That can happen in a variety of fashions,
179
      // so we have to consult AtEnd().
180
      return (AtEnd() && typed_other->AtEnd()) ||
181
         ($for j  && [[
182
 
183
          current$(j)_ == typed_other->current$(j)_
184
]]);
185
    }
186
 
187
   private:
188
    Iterator(const Iterator& other)
189
        : base_(other.base_), $for j, [[
190
 
191
        begin$(j)_(other.begin$(j)_),
192
        end$(j)_(other.end$(j)_),
193
        current$(j)_(other.current$(j)_)
194
]] {
195
      ComputeCurrentValue();
196
    }
197
 
198
    void ComputeCurrentValue() {
199
      if (!AtEnd())
200
        current_value_ = ParamType($for j, [[*current$(j)_]]);
201
    }
202
    bool AtEnd() const {
203
      // We must report iterator past the end of the range when either of the
204
      // component iterators has reached the end of its range.
205
      return
206
$for j  || [[
207
 
208
          current$(j)_ == end$(j)_
209
]];
210
    }
211
 
212
    // No implementation - assignment is unsupported.
213
    void operator=(const Iterator& other);
214
 
215
    const ParamGeneratorInterface* const base_;
216
    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
217
    // current[i]_ is the actual traversing iterator.
218
$for j [[
219
 
220
    const typename ParamGenerator::iterator begin$(j)_;
221
    const typename ParamGenerator::iterator end$(j)_;
222
    typename ParamGenerator::iterator current$(j)_;
223
]]
224
 
225
    ParamType current_value_;
226
  };  // class CartesianProductGenerator$i::Iterator
227
 
228
  // No implementation - assignment is unsupported.
229
  void operator=(const CartesianProductGenerator$i& other);
230
 
231
 
232
$for j [[
233
  const ParamGenerator g$(j)_;
234
 
235
]]
236
};  // class CartesianProductGenerator$i
237
 
238
 
239
]]
240
 
241
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
242
//
243
// Helper classes providing Combine() with polymorphic features. They allow
244
// casting CartesianProductGeneratorN to ParamGenerator if T is
245
// convertible to U.
246
//
247
$range i 2..maxtuple
248
$for i [[
249
$range j 1..i
250
 
251
template <$for j, [[class Generator$j]]>
252
class CartesianProductHolder$i {
253
 public:
254
CartesianProductHolder$i($for j, [[const Generator$j& g$j]])
255
      : $for j, [[g$(j)_(g$j)]] {}
256
  template <$for j, [[typename T$j]]>
257
  operator ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >() const {
258
    return ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >(
259
        new CartesianProductGenerator$i<$for j, [[T$j]]>(
260
$for j,[[
261
 
262
        static_cast >(g$(j)_)
263
]]));
264
  }
265
 
266
 private:
267
  // No implementation - assignment is unsupported.
268
  void operator=(const CartesianProductHolder$i& other);
269
 
270
 
271
$for j [[
272
  const Generator$j g$(j)_;
273
 
274
]]
275
};  // class CartesianProductHolder$i
276
 
277
]]
278
 
279
# endif  // GTEST_HAS_COMBINE
280
 
281
}  // namespace internal
282
}  // namespace testing
283
 
284
#endif  //  GTEST_HAS_PARAM_TEST
285
 
286
#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.