/firmware/tests/gtest-1.4.0/include/gtest/internal/gtest-param-util-generated.h.pump

http://github.com/makerbot/G3Firmware · Unknown · 284 lines · 229 code · 55 blank · 0 comment · 0 complexity · 73e9d4c76662d8a7ac3cff76504b130a MD5 · raw file

  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. // Type and function utilities for implementing parameterized tests.
  35. // This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
  36. //
  37. // Currently Google Test supports at most $n arguments in Values,
  38. // and at most $maxtuple arguments in Combine. Please contact
  39. // googletestframework@googlegroups.com if you need more.
  40. // Please note that the number of arguments to Combine is limited
  41. // by the maximum arity of the implementation of tr1::tuple which is
  42. // currently set at $maxtuple.
  43. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
  44. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
  45. #include <gtest/internal/gtest-port.h>
  46. #if GTEST_HAS_PARAM_TEST
  47. #include <gtest/internal/gtest-param-util.h>
  48. namespace testing {
  49. namespace internal {
  50. // Used in the Values() function to provide polymorphic capabilities.
  51. template <typename T1>
  52. class ValueArray1 {
  53. public:
  54. explicit ValueArray1(T1 v1) : v1_(v1) {}
  55. template <typename T>
  56. operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
  57. private:
  58. // No implementation - assignment is unsupported.
  59. void operator=(const ValueArray1& other);
  60. const T1 v1_;
  61. };
  62. $range i 2..n
  63. $for i [[
  64. $range j 1..i
  65. template <$for j, [[typename T$j]]>
  66. class ValueArray$i {
  67. public:
  68. ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {}
  69. template <typename T>
  70. operator ParamGenerator<T>() const {
  71. const T array[] = {$for j, [[v$(j)_]]};
  72. return ValuesIn(array);
  73. }
  74. private:
  75. // No implementation - assignment is unsupported.
  76. void operator=(const ValueArray$i& other);
  77. $for j [[
  78. const T$j v$(j)_;
  79. ]]
  80. };
  81. ]]
  82. #if GTEST_HAS_COMBINE
  83. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  84. //
  85. // Generates values from the Cartesian product of values produced
  86. // by the argument generators.
  87. //
  88. $range i 2..maxtuple
  89. $for i [[
  90. $range j 1..i
  91. $range k 2..i
  92. template <$for j, [[typename T$j]]>
  93. class CartesianProductGenerator$i
  94. : public ParamGeneratorInterface< ::std::tr1::tuple<$for j, [[T$j]]> > {
  95. public:
  96. typedef ::std::tr1::tuple<$for j, [[T$j]]> ParamType;
  97. CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])
  98. : $for j, [[g$(j)_(g$j)]] {}
  99. virtual ~CartesianProductGenerator$i() {}
  100. virtual ParamIteratorInterface<ParamType>* Begin() const {
  101. return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);
  102. }
  103. virtual ParamIteratorInterface<ParamType>* End() const {
  104. return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);
  105. }
  106. private:
  107. class Iterator : public ParamIteratorInterface<ParamType> {
  108. public:
  109. Iterator(const ParamGeneratorInterface<ParamType>* base, $for j, [[
  110. const ParamGenerator<T$j>& g$j,
  111. const typename ParamGenerator<T$j>::iterator& current$(j)]])
  112. : base_(base),
  113. $for j, [[
  114. begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j)
  115. ]] {
  116. ComputeCurrentValue();
  117. }
  118. virtual ~Iterator() {}
  119. virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
  120. return base_;
  121. }
  122. // Advance should not be called on beyond-of-range iterators
  123. // so no component iterators must be beyond end of range, either.
  124. virtual void Advance() {
  125. assert(!AtEnd());
  126. ++current$(i)_;
  127. $for k [[
  128. if (current$(i+2-k)_ == end$(i+2-k)_) {
  129. current$(i+2-k)_ = begin$(i+2-k)_;
  130. ++current$(i+2-k-1)_;
  131. }
  132. ]]
  133. ComputeCurrentValue();
  134. }
  135. virtual ParamIteratorInterface<ParamType>* Clone() const {
  136. return new Iterator(*this);
  137. }
  138. virtual const ParamType* Current() const { return &current_value_; }
  139. virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
  140. // Having the same base generator guarantees that the other
  141. // iterator is of the same type and we can downcast.
  142. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  143. << "The program attempted to compare iterators "
  144. << "from different generators." << std::endl;
  145. const Iterator* typed_other =
  146. CheckedDowncastToActualType<const Iterator>(&other);
  147. // We must report iterators equal if they both point beyond their
  148. // respective ranges. That can happen in a variety of fashions,
  149. // so we have to consult AtEnd().
  150. return (AtEnd() && typed_other->AtEnd()) ||
  151. ($for j && [[
  152. current$(j)_ == typed_other->current$(j)_
  153. ]]);
  154. }
  155. private:
  156. Iterator(const Iterator& other)
  157. : base_(other.base_), $for j, [[
  158. begin$(j)_(other.begin$(j)_),
  159. end$(j)_(other.end$(j)_),
  160. current$(j)_(other.current$(j)_)
  161. ]] {
  162. ComputeCurrentValue();
  163. }
  164. void ComputeCurrentValue() {
  165. if (!AtEnd())
  166. current_value_ = ParamType($for j, [[*current$(j)_]]);
  167. }
  168. bool AtEnd() const {
  169. // We must report iterator past the end of the range when either of the
  170. // component iterators has reached the end of its range.
  171. return
  172. $for j || [[
  173. current$(j)_ == end$(j)_
  174. ]];
  175. }
  176. // No implementation - assignment is unsupported.
  177. void operator=(const Iterator& other);
  178. const ParamGeneratorInterface<ParamType>* const base_;
  179. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  180. // current[i]_ is the actual traversing iterator.
  181. $for j [[
  182. const typename ParamGenerator<T$j>::iterator begin$(j)_;
  183. const typename ParamGenerator<T$j>::iterator end$(j)_;
  184. typename ParamGenerator<T$j>::iterator current$(j)_;
  185. ]]
  186. ParamType current_value_;
  187. }; // class CartesianProductGenerator$i::Iterator
  188. // No implementation - assignment is unsupported.
  189. void operator=(const CartesianProductGenerator$i& other);
  190. $for j [[
  191. const ParamGenerator<T$j> g$(j)_;
  192. ]]
  193. }; // class CartesianProductGenerator$i
  194. ]]
  195. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  196. //
  197. // Helper classes providing Combine() with polymorphic features. They allow
  198. // casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
  199. // convertible to U.
  200. //
  201. $range i 2..maxtuple
  202. $for i [[
  203. $range j 1..i
  204. template <$for j, [[class Generator$j]]>
  205. class CartesianProductHolder$i {
  206. public:
  207. CartesianProductHolder$i($for j, [[const Generator$j& g$j]])
  208. : $for j, [[g$(j)_(g$j)]] {}
  209. template <$for j, [[typename T$j]]>
  210. operator ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >() const {
  211. return ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >(
  212. new CartesianProductGenerator$i<$for j, [[T$j]]>(
  213. $for j,[[
  214. static_cast<ParamGenerator<T$j> >(g$(j)_)
  215. ]]));
  216. }
  217. private:
  218. // No implementation - assignment is unsupported.
  219. void operator=(const CartesianProductHolder$i& other);
  220. $for j [[
  221. const Generator$j g$(j)_;
  222. ]]
  223. }; // class CartesianProductHolder$i
  224. ]]
  225. #endif // GTEST_HAS_COMBINE
  226. } // namespace internal
  227. } // namespace testing
  228. #endif // GTEST_HAS_PARAM_TEST
  229. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_