cppjieba_rb 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +3 -0
  3. data/README.md +1 -1
  4. data/Rakefile +2 -2
  5. data/cppjieba_rb.gemspec +4 -4
  6. data/lib/cppjieba_rb/version.rb +1 -1
  7. metadata +17 -135
  8. data/ext/cppjieba/.gitignore +0 -17
  9. data/ext/cppjieba/.travis.yml +0 -21
  10. data/ext/cppjieba/CMakeLists.txt +0 -28
  11. data/ext/cppjieba/ChangeLog.md +0 -236
  12. data/ext/cppjieba/README.md +0 -292
  13. data/ext/cppjieba/README_EN.md +0 -113
  14. data/ext/cppjieba/appveyor.yml +0 -32
  15. data/ext/cppjieba/deps/CMakeLists.txt +0 -1
  16. data/ext/cppjieba/deps/gtest/CMakeLists.txt +0 -5
  17. data/ext/cppjieba/deps/gtest/include/gtest/gtest-death-test.h +0 -283
  18. data/ext/cppjieba/deps/gtest/include/gtest/gtest-message.h +0 -230
  19. data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h +0 -1421
  20. data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h.pump +0 -487
  21. data/ext/cppjieba/deps/gtest/include/gtest/gtest-printers.h +0 -796
  22. data/ext/cppjieba/deps/gtest/include/gtest/gtest-spi.h +0 -232
  23. data/ext/cppjieba/deps/gtest/include/gtest/gtest-test-part.h +0 -176
  24. data/ext/cppjieba/deps/gtest/include/gtest/gtest-typed-test.h +0 -259
  25. data/ext/cppjieba/deps/gtest/include/gtest/gtest.h +0 -2155
  26. data/ext/cppjieba/deps/gtest/include/gtest/gtest_pred_impl.h +0 -358
  27. data/ext/cppjieba/deps/gtest/include/gtest/gtest_prod.h +0 -58
  28. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-death-test-internal.h +0 -308
  29. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-filepath.h +0 -210
  30. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-internal.h +0 -1226
  31. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-linked_ptr.h +0 -233
  32. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h +0 -4822
  33. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +0 -301
  34. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util.h +0 -619
  35. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-port.h +0 -1788
  36. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-string.h +0 -350
  37. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h +0 -968
  38. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h.pump +0 -336
  39. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h +0 -3330
  40. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h.pump +0 -296
  41. data/ext/cppjieba/deps/gtest/src/.deps/.dirstamp +0 -0
  42. data/ext/cppjieba/deps/gtest/src/.deps/gtest-all.Plo +0 -681
  43. data/ext/cppjieba/deps/gtest/src/.deps/gtest_main.Plo +0 -509
  44. data/ext/cppjieba/deps/gtest/src/.dirstamp +0 -0
  45. data/ext/cppjieba/deps/gtest/src/gtest-all.cc +0 -48
  46. data/ext/cppjieba/deps/gtest/src/gtest-death-test.cc +0 -1234
  47. data/ext/cppjieba/deps/gtest/src/gtest-filepath.cc +0 -380
  48. data/ext/cppjieba/deps/gtest/src/gtest-internal-inl.h +0 -1038
  49. data/ext/cppjieba/deps/gtest/src/gtest-port.cc +0 -746
  50. data/ext/cppjieba/deps/gtest/src/gtest-printers.cc +0 -356
  51. data/ext/cppjieba/deps/gtest/src/gtest-test-part.cc +0 -110
  52. data/ext/cppjieba/deps/gtest/src/gtest-typed-test.cc +0 -110
  53. data/ext/cppjieba/deps/gtest/src/gtest.cc +0 -4898
  54. data/ext/cppjieba/deps/gtest/src/gtest_main.cc +0 -39
  55. data/ext/cppjieba/deps/limonp/ArgvContext.hpp +0 -70
  56. data/ext/cppjieba/deps/limonp/BlockingQueue.hpp +0 -49
  57. data/ext/cppjieba/deps/limonp/BoundedBlockingQueue.hpp +0 -67
  58. data/ext/cppjieba/deps/limonp/BoundedQueue.hpp +0 -65
  59. data/ext/cppjieba/deps/limonp/Closure.hpp +0 -206
  60. data/ext/cppjieba/deps/limonp/Colors.hpp +0 -31
  61. data/ext/cppjieba/deps/limonp/Condition.hpp +0 -38
  62. data/ext/cppjieba/deps/limonp/Config.hpp +0 -103
  63. data/ext/cppjieba/deps/limonp/FileLock.hpp +0 -74
  64. data/ext/cppjieba/deps/limonp/ForcePublic.hpp +0 -7
  65. data/ext/cppjieba/deps/limonp/LocalVector.hpp +0 -139
  66. data/ext/cppjieba/deps/limonp/Logging.hpp +0 -76
  67. data/ext/cppjieba/deps/limonp/Md5.hpp +0 -411
  68. data/ext/cppjieba/deps/limonp/MutexLock.hpp +0 -51
  69. data/ext/cppjieba/deps/limonp/NonCopyable.hpp +0 -21
  70. data/ext/cppjieba/deps/limonp/StdExtension.hpp +0 -159
  71. data/ext/cppjieba/deps/limonp/StringUtil.hpp +0 -365
  72. data/ext/cppjieba/deps/limonp/Thread.hpp +0 -44
  73. data/ext/cppjieba/deps/limonp/ThreadPool.hpp +0 -86
  74. data/ext/cppjieba/dict/README.md +0 -31
  75. data/ext/cppjieba/dict/hmm_model.utf8 +0 -34
  76. data/ext/cppjieba/dict/idf.utf8 +0 -258826
  77. data/ext/cppjieba/dict/jieba.dict.utf8 +0 -348982
  78. data/ext/cppjieba/dict/pos_dict/char_state_tab.utf8 +0 -6653
  79. data/ext/cppjieba/dict/pos_dict/prob_emit.utf8 +0 -166
  80. data/ext/cppjieba/dict/pos_dict/prob_start.utf8 +0 -259
  81. data/ext/cppjieba/dict/pos_dict/prob_trans.utf8 +0 -5222
  82. data/ext/cppjieba/dict/stop_words.utf8 +0 -1534
  83. data/ext/cppjieba/dict/user.dict.utf8 +0 -4
  84. data/ext/cppjieba/include/cppjieba/DictTrie.hpp +0 -277
  85. data/ext/cppjieba/include/cppjieba/FullSegment.hpp +0 -93
  86. data/ext/cppjieba/include/cppjieba/HMMModel.hpp +0 -129
  87. data/ext/cppjieba/include/cppjieba/HMMSegment.hpp +0 -190
  88. data/ext/cppjieba/include/cppjieba/Jieba.hpp +0 -130
  89. data/ext/cppjieba/include/cppjieba/KeywordExtractor.hpp +0 -153
  90. data/ext/cppjieba/include/cppjieba/MPSegment.hpp +0 -137
  91. data/ext/cppjieba/include/cppjieba/MixSegment.hpp +0 -109
  92. data/ext/cppjieba/include/cppjieba/PosTagger.hpp +0 -77
  93. data/ext/cppjieba/include/cppjieba/PreFilter.hpp +0 -54
  94. data/ext/cppjieba/include/cppjieba/QuerySegment.hpp +0 -90
  95. data/ext/cppjieba/include/cppjieba/SegmentBase.hpp +0 -46
  96. data/ext/cppjieba/include/cppjieba/SegmentTagged.hpp +0 -23
  97. data/ext/cppjieba/include/cppjieba/TextRankExtractor.hpp +0 -190
  98. data/ext/cppjieba/include/cppjieba/Trie.hpp +0 -174
  99. data/ext/cppjieba/include/cppjieba/Unicode.hpp +0 -227
  100. data/ext/cppjieba/test/CMakeLists.txt +0 -5
  101. data/ext/cppjieba/test/demo.cpp +0 -80
  102. data/ext/cppjieba/test/load_test.cpp +0 -54
  103. data/ext/cppjieba/test/testdata/curl.res +0 -1
  104. data/ext/cppjieba/test/testdata/extra_dict/jieba.dict.small.utf8 +0 -109750
  105. data/ext/cppjieba/test/testdata/gbk_dict/hmm_model.gbk +0 -34
  106. data/ext/cppjieba/test/testdata/gbk_dict/jieba.dict.gbk +0 -348982
  107. data/ext/cppjieba/test/testdata/jieba.dict.0.1.utf8 +0 -93
  108. data/ext/cppjieba/test/testdata/jieba.dict.0.utf8 +0 -93
  109. data/ext/cppjieba/test/testdata/jieba.dict.1.utf8 +0 -67
  110. data/ext/cppjieba/test/testdata/jieba.dict.2.utf8 +0 -64
  111. data/ext/cppjieba/test/testdata/load_test.urls +0 -2
  112. data/ext/cppjieba/test/testdata/review.100 +0 -100
  113. data/ext/cppjieba/test/testdata/review.100.res +0 -200
  114. data/ext/cppjieba/test/testdata/server.conf +0 -19
  115. data/ext/cppjieba/test/testdata/testlines.gbk +0 -9
  116. data/ext/cppjieba/test/testdata/testlines.utf8 +0 -8
  117. data/ext/cppjieba/test/testdata/userdict.2.utf8 +0 -1
  118. data/ext/cppjieba/test/testdata/userdict.english +0 -2
  119. data/ext/cppjieba/test/testdata/userdict.utf8 +0 -8
  120. data/ext/cppjieba/test/testdata/weicheng.utf8 +0 -247
  121. data/ext/cppjieba/test/unittest/CMakeLists.txt +0 -24
  122. data/ext/cppjieba/test/unittest/gtest_main.cpp +0 -39
  123. data/ext/cppjieba/test/unittest/jieba_test.cpp +0 -133
  124. data/ext/cppjieba/test/unittest/keyword_extractor_test.cpp +0 -79
  125. data/ext/cppjieba/test/unittest/pos_tagger_test.cpp +0 -41
  126. data/ext/cppjieba/test/unittest/pre_filter_test.cpp +0 -43
  127. data/ext/cppjieba/test/unittest/segments_test.cpp +0 -256
  128. data/ext/cppjieba/test/unittest/textrank_test.cpp +0 -86
  129. data/ext/cppjieba/test/unittest/trie_test.cpp +0 -177
  130. data/ext/cppjieba/test/unittest/unicode_test.cpp +0 -43
@@ -1,301 +0,0 @@
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 tr1::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 <typename ForwardIterator>
61
- internal::ParamGenerator<
62
- typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
63
- ValuesIn(ForwardIterator begin, ForwardIterator end);
64
-
65
- template <typename T, size_t N>
66
- internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
67
-
68
- template <class Container>
69
- internal::ParamGenerator<typename Container::value_type> ValuesIn(
70
- const Container& container);
71
-
72
- namespace internal {
73
-
74
- // Used in the Values() function to provide polymorphic capabilities.
75
- template <typename T1>
76
- class ValueArray1 {
77
- public:
78
- explicit ValueArray1(T1 v1) : v1_(v1) {}
79
-
80
- template <typename T>
81
- operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
82
-
83
- private:
84
- // No implementation - assignment is unsupported.
85
- void operator=(const ValueArray1& other);
86
-
87
- const T1 v1_;
88
- };
89
-
90
- $range i 2..n
91
- $for i [[
92
- $range j 1..i
93
-
94
- template <$for j, [[typename T$j]]>
95
- class ValueArray$i {
96
- public:
97
- ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {}
98
-
99
- template <typename T>
100
- operator ParamGenerator<T>() const {
101
- const T array[] = {$for j, [[v$(j)_]]};
102
- return ValuesIn(array);
103
- }
104
-
105
- private:
106
- // No implementation - assignment is unsupported.
107
- void operator=(const ValueArray$i& other);
108
-
109
- $for j [[
110
-
111
- const T$j v$(j)_;
112
- ]]
113
-
114
- };
115
-
116
- ]]
117
-
118
- # if GTEST_HAS_COMBINE
119
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
120
- //
121
- // Generates values from the Cartesian product of values produced
122
- // by the argument generators.
123
- //
124
- $range i 2..maxtuple
125
- $for i [[
126
- $range j 1..i
127
- $range k 2..i
128
-
129
- template <$for j, [[typename T$j]]>
130
- class CartesianProductGenerator$i
131
- : public ParamGeneratorInterface< ::std::tr1::tuple<$for j, [[T$j]]> > {
132
- public:
133
- typedef ::std::tr1::tuple<$for j, [[T$j]]> ParamType;
134
-
135
- CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])
136
- : $for j, [[g$(j)_(g$j)]] {}
137
- virtual ~CartesianProductGenerator$i() {}
138
-
139
- virtual ParamIteratorInterface<ParamType>* Begin() const {
140
- return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);
141
- }
142
- virtual ParamIteratorInterface<ParamType>* End() const {
143
- return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);
144
- }
145
-
146
- private:
147
- class Iterator : public ParamIteratorInterface<ParamType> {
148
- public:
149
- Iterator(const ParamGeneratorInterface<ParamType>* base, $for j, [[
150
-
151
- const ParamGenerator<T$j>& g$j,
152
- const typename ParamGenerator<T$j>::iterator& current$(j)]])
153
- : base_(base),
154
- $for j, [[
155
-
156
- begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j)
157
- ]] {
158
- ComputeCurrentValue();
159
- }
160
- virtual ~Iterator() {}
161
-
162
- virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
163
- return base_;
164
- }
165
- // Advance should not be called on beyond-of-range iterators
166
- // so no component iterators must be beyond end of range, either.
167
- virtual void Advance() {
168
- assert(!AtEnd());
169
- ++current$(i)_;
170
-
171
- $for k [[
172
- if (current$(i+2-k)_ == end$(i+2-k)_) {
173
- current$(i+2-k)_ = begin$(i+2-k)_;
174
- ++current$(i+2-k-1)_;
175
- }
176
-
177
- ]]
178
- ComputeCurrentValue();
179
- }
180
- virtual ParamIteratorInterface<ParamType>* Clone() const {
181
- return new Iterator(*this);
182
- }
183
- virtual const ParamType* Current() const { return &current_value_; }
184
- virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
185
- // Having the same base generator guarantees that the other
186
- // iterator is of the same type and we can downcast.
187
- GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
188
- << "The program attempted to compare iterators "
189
- << "from different generators." << std::endl;
190
- const Iterator* typed_other =
191
- CheckedDowncastToActualType<const Iterator>(&other);
192
- // We must report iterators equal if they both point beyond their
193
- // respective ranges. That can happen in a variety of fashions,
194
- // so we have to consult AtEnd().
195
- return (AtEnd() && typed_other->AtEnd()) ||
196
- ($for j && [[
197
-
198
- current$(j)_ == typed_other->current$(j)_
199
- ]]);
200
- }
201
-
202
- private:
203
- Iterator(const Iterator& other)
204
- : base_(other.base_), $for j, [[
205
-
206
- begin$(j)_(other.begin$(j)_),
207
- end$(j)_(other.end$(j)_),
208
- current$(j)_(other.current$(j)_)
209
- ]] {
210
- ComputeCurrentValue();
211
- }
212
-
213
- void ComputeCurrentValue() {
214
- if (!AtEnd())
215
- current_value_ = ParamType($for j, [[*current$(j)_]]);
216
- }
217
- bool AtEnd() const {
218
- // We must report iterator past the end of the range when either of the
219
- // component iterators has reached the end of its range.
220
- return
221
- $for j || [[
222
-
223
- current$(j)_ == end$(j)_
224
- ]];
225
- }
226
-
227
- // No implementation - assignment is unsupported.
228
- void operator=(const Iterator& other);
229
-
230
- const ParamGeneratorInterface<ParamType>* const base_;
231
- // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
232
- // current[i]_ is the actual traversing iterator.
233
- $for j [[
234
-
235
- const typename ParamGenerator<T$j>::iterator begin$(j)_;
236
- const typename ParamGenerator<T$j>::iterator end$(j)_;
237
- typename ParamGenerator<T$j>::iterator current$(j)_;
238
- ]]
239
-
240
- ParamType current_value_;
241
- }; // class CartesianProductGenerator$i::Iterator
242
-
243
- // No implementation - assignment is unsupported.
244
- void operator=(const CartesianProductGenerator$i& other);
245
-
246
-
247
- $for j [[
248
- const ParamGenerator<T$j> g$(j)_;
249
-
250
- ]]
251
- }; // class CartesianProductGenerator$i
252
-
253
-
254
- ]]
255
-
256
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
257
- //
258
- // Helper classes providing Combine() with polymorphic features. They allow
259
- // casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
260
- // convertible to U.
261
- //
262
- $range i 2..maxtuple
263
- $for i [[
264
- $range j 1..i
265
-
266
- template <$for j, [[class Generator$j]]>
267
- class CartesianProductHolder$i {
268
- public:
269
- CartesianProductHolder$i($for j, [[const Generator$j& g$j]])
270
- : $for j, [[g$(j)_(g$j)]] {}
271
- template <$for j, [[typename T$j]]>
272
- operator ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >() const {
273
- return ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >(
274
- new CartesianProductGenerator$i<$for j, [[T$j]]>(
275
- $for j,[[
276
-
277
- static_cast<ParamGenerator<T$j> >(g$(j)_)
278
- ]]));
279
- }
280
-
281
- private:
282
- // No implementation - assignment is unsupported.
283
- void operator=(const CartesianProductHolder$i& other);
284
-
285
-
286
- $for j [[
287
- const Generator$j g$(j)_;
288
-
289
- ]]
290
- }; // class CartesianProductHolder$i
291
-
292
- ]]
293
-
294
- # endif // GTEST_HAS_COMBINE
295
-
296
- } // namespace internal
297
- } // namespace testing
298
-
299
- #endif // GTEST_HAS_PARAM_TEST
300
-
301
- #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
@@ -1,619 +0,0 @@
1
- // Copyright 2008 Google Inc.
2
- // All Rights Reserved.
3
- //
4
- // Redistribution and use in source and binary forms, with or without
5
- // modification, are permitted provided that the following conditions are
6
- // met:
7
- //
8
- // * Redistributions of source code must retain the above copyright
9
- // notice, this list of conditions and the following disclaimer.
10
- // * Redistributions in binary form must reproduce the above
11
- // copyright notice, this list of conditions and the following disclaimer
12
- // in the documentation and/or other materials provided with the
13
- // distribution.
14
- // * Neither the name of Google Inc. nor the names of its
15
- // contributors may be used to endorse or promote products derived from
16
- // this software without specific prior written permission.
17
- //
18
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
- //
30
- // Author: vladl@google.com (Vlad Losev)
31
-
32
- // Type and function utilities for implementing parameterized tests.
33
-
34
- #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
35
- #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
36
-
37
- #include <iterator>
38
- #include <utility>
39
- #include <vector>
40
-
41
- // scripts/fuse_gtest.py depends on gtest's own header being #included
42
- // *unconditionally*. Therefore these #includes cannot be moved
43
- // inside #if GTEST_HAS_PARAM_TEST.
44
- #include "gtest/internal/gtest-internal.h"
45
- #include "gtest/internal/gtest-linked_ptr.h"
46
- #include "gtest/internal/gtest-port.h"
47
- #include "gtest/gtest-printers.h"
48
-
49
- #if GTEST_HAS_PARAM_TEST
50
-
51
- namespace testing {
52
- namespace internal {
53
-
54
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
55
- //
56
- // Outputs a message explaining invalid registration of different
57
- // fixture class for the same test case. This may happen when
58
- // TEST_P macro is used to define two tests with the same name
59
- // but in different namespaces.
60
- GTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name,
61
- const char* file, int line);
62
-
63
- template <typename> class ParamGeneratorInterface;
64
- template <typename> class ParamGenerator;
65
-
66
- // Interface for iterating over elements provided by an implementation
67
- // of ParamGeneratorInterface<T>.
68
- template <typename T>
69
- class ParamIteratorInterface {
70
- public:
71
- virtual ~ParamIteratorInterface() {}
72
- // A pointer to the base generator instance.
73
- // Used only for the purposes of iterator comparison
74
- // to make sure that two iterators belong to the same generator.
75
- virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
76
- // Advances iterator to point to the next element
77
- // provided by the generator. The caller is responsible
78
- // for not calling Advance() on an iterator equal to
79
- // BaseGenerator()->End().
80
- virtual void Advance() = 0;
81
- // Clones the iterator object. Used for implementing copy semantics
82
- // of ParamIterator<T>.
83
- virtual ParamIteratorInterface* Clone() const = 0;
84
- // Dereferences the current iterator and provides (read-only) access
85
- // to the pointed value. It is the caller's responsibility not to call
86
- // Current() on an iterator equal to BaseGenerator()->End().
87
- // Used for implementing ParamGenerator<T>::operator*().
88
- virtual const T* Current() const = 0;
89
- // Determines whether the given iterator and other point to the same
90
- // element in the sequence generated by the generator.
91
- // Used for implementing ParamGenerator<T>::operator==().
92
- virtual bool Equals(const ParamIteratorInterface& other) const = 0;
93
- };
94
-
95
- // Class iterating over elements provided by an implementation of
96
- // ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>
97
- // and implements the const forward iterator concept.
98
- template <typename T>
99
- class ParamIterator {
100
- public:
101
- typedef T value_type;
102
- typedef const T& reference;
103
- typedef ptrdiff_t difference_type;
104
-
105
- // ParamIterator assumes ownership of the impl_ pointer.
106
- ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
107
- ParamIterator& operator=(const ParamIterator& other) {
108
- if (this != &other)
109
- impl_.reset(other.impl_->Clone());
110
- return *this;
111
- }
112
-
113
- const T& operator*() const { return *impl_->Current(); }
114
- const T* operator->() const { return impl_->Current(); }
115
- // Prefix version of operator++.
116
- ParamIterator& operator++() {
117
- impl_->Advance();
118
- return *this;
119
- }
120
- // Postfix version of operator++.
121
- ParamIterator operator++(int /*unused*/) {
122
- ParamIteratorInterface<T>* clone = impl_->Clone();
123
- impl_->Advance();
124
- return ParamIterator(clone);
125
- }
126
- bool operator==(const ParamIterator& other) const {
127
- return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
128
- }
129
- bool operator!=(const ParamIterator& other) const {
130
- return !(*this == other);
131
- }
132
-
133
- private:
134
- friend class ParamGenerator<T>;
135
- explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
136
- scoped_ptr<ParamIteratorInterface<T> > impl_;
137
- };
138
-
139
- // ParamGeneratorInterface<T> is the binary interface to access generators
140
- // defined in other translation units.
141
- template <typename T>
142
- class ParamGeneratorInterface {
143
- public:
144
- typedef T ParamType;
145
-
146
- virtual ~ParamGeneratorInterface() {}
147
-
148
- // Generator interface definition
149
- virtual ParamIteratorInterface<T>* Begin() const = 0;
150
- virtual ParamIteratorInterface<T>* End() const = 0;
151
- };
152
-
153
- // Wraps ParamGeneratorInterface<T> and provides general generator syntax
154
- // compatible with the STL Container concept.
155
- // This class implements copy initialization semantics and the contained
156
- // ParamGeneratorInterface<T> instance is shared among all copies
157
- // of the original object. This is possible because that instance is immutable.
158
- template<typename T>
159
- class ParamGenerator {
160
- public:
161
- typedef ParamIterator<T> iterator;
162
-
163
- explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
164
- ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
165
-
166
- ParamGenerator& operator=(const ParamGenerator& other) {
167
- impl_ = other.impl_;
168
- return *this;
169
- }
170
-
171
- iterator begin() const { return iterator(impl_->Begin()); }
172
- iterator end() const { return iterator(impl_->End()); }
173
-
174
- private:
175
- linked_ptr<const ParamGeneratorInterface<T> > impl_;
176
- };
177
-
178
- // Generates values from a range of two comparable values. Can be used to
179
- // generate sequences of user-defined types that implement operator+() and
180
- // operator<().
181
- // This class is used in the Range() function.
182
- template <typename T, typename IncrementT>
183
- class RangeGenerator : public ParamGeneratorInterface<T> {
184
- public:
185
- RangeGenerator(T begin, T end, IncrementT step)
186
- : begin_(begin), end_(end),
187
- step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
188
- virtual ~RangeGenerator() {}
189
-
190
- virtual ParamIteratorInterface<T>* Begin() const {
191
- return new Iterator(this, begin_, 0, step_);
192
- }
193
- virtual ParamIteratorInterface<T>* End() const {
194
- return new Iterator(this, end_, end_index_, step_);
195
- }
196
-
197
- private:
198
- class Iterator : public ParamIteratorInterface<T> {
199
- public:
200
- Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
201
- IncrementT step)
202
- : base_(base), value_(value), index_(index), step_(step) {}
203
- virtual ~Iterator() {}
204
-
205
- virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
206
- return base_;
207
- }
208
- virtual void Advance() {
209
- value_ = value_ + step_;
210
- index_++;
211
- }
212
- virtual ParamIteratorInterface<T>* Clone() const {
213
- return new Iterator(*this);
214
- }
215
- virtual const T* Current() const { return &value_; }
216
- virtual bool Equals(const ParamIteratorInterface<T>& other) const {
217
- // Having the same base generator guarantees that the other
218
- // iterator is of the same type and we can downcast.
219
- GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
220
- << "The program attempted to compare iterators "
221
- << "from different generators." << std::endl;
222
- const int other_index =
223
- CheckedDowncastToActualType<const Iterator>(&other)->index_;
224
- return index_ == other_index;
225
- }
226
-
227
- private:
228
- Iterator(const Iterator& other)
229
- : ParamIteratorInterface<T>(),
230
- base_(other.base_), value_(other.value_), index_(other.index_),
231
- step_(other.step_) {}
232
-
233
- // No implementation - assignment is unsupported.
234
- void operator=(const Iterator& other);
235
-
236
- const ParamGeneratorInterface<T>* const base_;
237
- T value_;
238
- int index_;
239
- const IncrementT step_;
240
- }; // class RangeGenerator::Iterator
241
-
242
- static int CalculateEndIndex(const T& begin,
243
- const T& end,
244
- const IncrementT& step) {
245
- int end_index = 0;
246
- for (T i = begin; i < end; i = i + step)
247
- end_index++;
248
- return end_index;
249
- }
250
-
251
- // No implementation - assignment is unsupported.
252
- void operator=(const RangeGenerator& other);
253
-
254
- const T begin_;
255
- const T end_;
256
- const IncrementT step_;
257
- // The index for the end() iterator. All the elements in the generated
258
- // sequence are indexed (0-based) to aid iterator comparison.
259
- const int end_index_;
260
- }; // class RangeGenerator
261
-
262
-
263
- // Generates values from a pair of STL-style iterators. Used in the
264
- // ValuesIn() function. The elements are copied from the source range
265
- // since the source can be located on the stack, and the generator
266
- // is likely to persist beyond that stack frame.
267
- template <typename T>
268
- class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
269
- public:
270
- template <typename ForwardIterator>
271
- ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
272
- : container_(begin, end) {}
273
- virtual ~ValuesInIteratorRangeGenerator() {}
274
-
275
- virtual ParamIteratorInterface<T>* Begin() const {
276
- return new Iterator(this, container_.begin());
277
- }
278
- virtual ParamIteratorInterface<T>* End() const {
279
- return new Iterator(this, container_.end());
280
- }
281
-
282
- private:
283
- typedef typename ::std::vector<T> ContainerType;
284
-
285
- class Iterator : public ParamIteratorInterface<T> {
286
- public:
287
- Iterator(const ParamGeneratorInterface<T>* base,
288
- typename ContainerType::const_iterator iterator)
289
- : base_(base), iterator_(iterator) {}
290
- virtual ~Iterator() {}
291
-
292
- virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
293
- return base_;
294
- }
295
- virtual void Advance() {
296
- ++iterator_;
297
- value_.reset();
298
- }
299
- virtual ParamIteratorInterface<T>* Clone() const {
300
- return new Iterator(*this);
301
- }
302
- // We need to use cached value referenced by iterator_ because *iterator_
303
- // can return a temporary object (and of type other then T), so just
304
- // having "return &*iterator_;" doesn't work.
305
- // value_ is updated here and not in Advance() because Advance()
306
- // can advance iterator_ beyond the end of the range, and we cannot
307
- // detect that fact. The client code, on the other hand, is
308
- // responsible for not calling Current() on an out-of-range iterator.
309
- virtual const T* Current() const {
310
- if (value_.get() == NULL)
311
- value_.reset(new T(*iterator_));
312
- return value_.get();
313
- }
314
- virtual bool Equals(const ParamIteratorInterface<T>& other) const {
315
- // Having the same base generator guarantees that the other
316
- // iterator is of the same type and we can downcast.
317
- GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
318
- << "The program attempted to compare iterators "
319
- << "from different generators." << std::endl;
320
- return iterator_ ==
321
- CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
322
- }
323
-
324
- private:
325
- Iterator(const Iterator& other)
326
- // The explicit constructor call suppresses a false warning
327
- // emitted by gcc when supplied with the -Wextra option.
328
- : ParamIteratorInterface<T>(),
329
- base_(other.base_),
330
- iterator_(other.iterator_) {}
331
-
332
- const ParamGeneratorInterface<T>* const base_;
333
- typename ContainerType::const_iterator iterator_;
334
- // A cached value of *iterator_. We keep it here to allow access by
335
- // pointer in the wrapping iterator's operator->().
336
- // value_ needs to be mutable to be accessed in Current().
337
- // Use of scoped_ptr helps manage cached value's lifetime,
338
- // which is bound by the lifespan of the iterator itself.
339
- mutable scoped_ptr<const T> value_;
340
- }; // class ValuesInIteratorRangeGenerator::Iterator
341
-
342
- // No implementation - assignment is unsupported.
343
- void operator=(const ValuesInIteratorRangeGenerator& other);
344
-
345
- const ContainerType container_;
346
- }; // class ValuesInIteratorRangeGenerator
347
-
348
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
349
- //
350
- // Stores a parameter value and later creates tests parameterized with that
351
- // value.
352
- template <class TestClass>
353
- class ParameterizedTestFactory : public TestFactoryBase {
354
- public:
355
- typedef typename TestClass::ParamType ParamType;
356
- explicit ParameterizedTestFactory(ParamType parameter) :
357
- parameter_(parameter) {}
358
- virtual Test* CreateTest() {
359
- TestClass::SetParam(&parameter_);
360
- return new TestClass();
361
- }
362
-
363
- private:
364
- const ParamType parameter_;
365
-
366
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
367
- };
368
-
369
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
370
- //
371
- // TestMetaFactoryBase is a base class for meta-factories that create
372
- // test factories for passing into MakeAndRegisterTestInfo function.
373
- template <class ParamType>
374
- class TestMetaFactoryBase {
375
- public:
376
- virtual ~TestMetaFactoryBase() {}
377
-
378
- virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
379
- };
380
-
381
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
382
- //
383
- // TestMetaFactory creates test factories for passing into
384
- // MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives
385
- // ownership of test factory pointer, same factory object cannot be passed
386
- // into that method twice. But ParameterizedTestCaseInfo is going to call
387
- // it for each Test/Parameter value combination. Thus it needs meta factory
388
- // creator class.
389
- template <class TestCase>
390
- class TestMetaFactory
391
- : public TestMetaFactoryBase<typename TestCase::ParamType> {
392
- public:
393
- typedef typename TestCase::ParamType ParamType;
394
-
395
- TestMetaFactory() {}
396
-
397
- virtual TestFactoryBase* CreateTestFactory(ParamType parameter) {
398
- return new ParameterizedTestFactory<TestCase>(parameter);
399
- }
400
-
401
- private:
402
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
403
- };
404
-
405
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
406
- //
407
- // ParameterizedTestCaseInfoBase is a generic interface
408
- // to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase
409
- // accumulates test information provided by TEST_P macro invocations
410
- // and generators provided by INSTANTIATE_TEST_CASE_P macro invocations
411
- // and uses that information to register all resulting test instances
412
- // in RegisterTests method. The ParameterizeTestCaseRegistry class holds
413
- // a collection of pointers to the ParameterizedTestCaseInfo objects
414
- // and calls RegisterTests() on each of them when asked.
415
- class ParameterizedTestCaseInfoBase {
416
- public:
417
- virtual ~ParameterizedTestCaseInfoBase() {}
418
-
419
- // Base part of test case name for display purposes.
420
- virtual const string& GetTestCaseName() const = 0;
421
- // Test case id to verify identity.
422
- virtual TypeId GetTestCaseTypeId() const = 0;
423
- // UnitTest class invokes this method to register tests in this
424
- // test case right before running them in RUN_ALL_TESTS macro.
425
- // This method should not be called more then once on any single
426
- // instance of a ParameterizedTestCaseInfoBase derived class.
427
- virtual void RegisterTests() = 0;
428
-
429
- protected:
430
- ParameterizedTestCaseInfoBase() {}
431
-
432
- private:
433
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase);
434
- };
435
-
436
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
437
- //
438
- // ParameterizedTestCaseInfo accumulates tests obtained from TEST_P
439
- // macro invocations for a particular test case and generators
440
- // obtained from INSTANTIATE_TEST_CASE_P macro invocations for that
441
- // test case. It registers tests with all values generated by all
442
- // generators when asked.
443
- template <class TestCase>
444
- class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
445
- public:
446
- // ParamType and GeneratorCreationFunc are private types but are required
447
- // for declarations of public methods AddTestPattern() and
448
- // AddTestCaseInstantiation().
449
- typedef typename TestCase::ParamType ParamType;
450
- // A function that returns an instance of appropriate generator type.
451
- typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
452
-
453
- explicit ParameterizedTestCaseInfo(const char* name)
454
- : test_case_name_(name) {}
455
-
456
- // Test case base name for display purposes.
457
- virtual const string& GetTestCaseName() const { return test_case_name_; }
458
- // Test case id to verify identity.
459
- virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }
460
- // TEST_P macro uses AddTestPattern() to record information
461
- // about a single test in a LocalTestInfo structure.
462
- // test_case_name is the base name of the test case (without invocation
463
- // prefix). test_base_name is the name of an individual test without
464
- // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
465
- // test case base name and DoBar is test base name.
466
- void AddTestPattern(const char* test_case_name,
467
- const char* test_base_name,
468
- TestMetaFactoryBase<ParamType>* meta_factory) {
469
- tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name,
470
- test_base_name,
471
- meta_factory)));
472
- }
473
- // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information
474
- // about a generator.
475
- int AddTestCaseInstantiation(const string& instantiation_name,
476
- GeneratorCreationFunc* func,
477
- const char* /* file */,
478
- int /* line */) {
479
- instantiations_.push_back(::std::make_pair(instantiation_name, func));
480
- return 0; // Return value used only to run this method in namespace scope.
481
- }
482
- // UnitTest class invokes this method to register tests in this test case
483
- // test cases right before running tests in RUN_ALL_TESTS macro.
484
- // This method should not be called more then once on any single
485
- // instance of a ParameterizedTestCaseInfoBase derived class.
486
- // UnitTest has a guard to prevent from calling this method more then once.
487
- virtual void RegisterTests() {
488
- for (typename TestInfoContainer::iterator test_it = tests_.begin();
489
- test_it != tests_.end(); ++test_it) {
490
- linked_ptr<TestInfo> test_info = *test_it;
491
- for (typename InstantiationContainer::iterator gen_it =
492
- instantiations_.begin(); gen_it != instantiations_.end();
493
- ++gen_it) {
494
- const string& instantiation_name = gen_it->first;
495
- ParamGenerator<ParamType> generator((*gen_it->second)());
496
-
497
- Message test_case_name_stream;
498
- if ( !instantiation_name.empty() )
499
- test_case_name_stream << instantiation_name << "/";
500
- test_case_name_stream << test_info->test_case_base_name;
501
-
502
- int i = 0;
503
- for (typename ParamGenerator<ParamType>::iterator param_it =
504
- generator.begin();
505
- param_it != generator.end(); ++param_it, ++i) {
506
- Message test_name_stream;
507
- test_name_stream << test_info->test_base_name << "/" << i;
508
- MakeAndRegisterTestInfo(
509
- test_case_name_stream.GetString().c_str(),
510
- test_name_stream.GetString().c_str(),
511
- NULL, // No type parameter.
512
- PrintToString(*param_it).c_str(),
513
- GetTestCaseTypeId(),
514
- TestCase::SetUpTestCase,
515
- TestCase::TearDownTestCase,
516
- test_info->test_meta_factory->CreateTestFactory(*param_it));
517
- } // for param_it
518
- } // for gen_it
519
- } // for test_it
520
- } // RegisterTests
521
-
522
- private:
523
- // LocalTestInfo structure keeps information about a single test registered
524
- // with TEST_P macro.
525
- struct TestInfo {
526
- TestInfo(const char* a_test_case_base_name,
527
- const char* a_test_base_name,
528
- TestMetaFactoryBase<ParamType>* a_test_meta_factory) :
529
- test_case_base_name(a_test_case_base_name),
530
- test_base_name(a_test_base_name),
531
- test_meta_factory(a_test_meta_factory) {}
532
-
533
- const string test_case_base_name;
534
- const string test_base_name;
535
- const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
536
- };
537
- typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;
538
- // Keeps pairs of <Instantiation name, Sequence generator creation function>
539
- // received from INSTANTIATE_TEST_CASE_P macros.
540
- typedef ::std::vector<std::pair<string, GeneratorCreationFunc*> >
541
- InstantiationContainer;
542
-
543
- const string test_case_name_;
544
- TestInfoContainer tests_;
545
- InstantiationContainer instantiations_;
546
-
547
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfo);
548
- }; // class ParameterizedTestCaseInfo
549
-
550
- // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
551
- //
552
- // ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase
553
- // classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P
554
- // macros use it to locate their corresponding ParameterizedTestCaseInfo
555
- // descriptors.
556
- class ParameterizedTestCaseRegistry {
557
- public:
558
- ParameterizedTestCaseRegistry() {}
559
- ~ParameterizedTestCaseRegistry() {
560
- for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
561
- it != test_case_infos_.end(); ++it) {
562
- delete *it;
563
- }
564
- }
565
-
566
- // Looks up or creates and returns a structure containing information about
567
- // tests and instantiations of a particular test case.
568
- template <class TestCase>
569
- ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
570
- const char* test_case_name,
571
- const char* file,
572
- int line) {
573
- ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL;
574
- for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
575
- it != test_case_infos_.end(); ++it) {
576
- if ((*it)->GetTestCaseName() == test_case_name) {
577
- if ((*it)->GetTestCaseTypeId() != GetTypeId<TestCase>()) {
578
- // Complain about incorrect usage of Google Test facilities
579
- // and terminate the program since we cannot guaranty correct
580
- // test case setup and tear-down in this case.
581
- ReportInvalidTestCaseType(test_case_name, file, line);
582
- posix::Abort();
583
- } else {
584
- // At this point we are sure that the object we found is of the same
585
- // type we are looking for, so we downcast it to that type
586
- // without further checks.
587
- typed_test_info = CheckedDowncastToActualType<
588
- ParameterizedTestCaseInfo<TestCase> >(*it);
589
- }
590
- break;
591
- }
592
- }
593
- if (typed_test_info == NULL) {
594
- typed_test_info = new ParameterizedTestCaseInfo<TestCase>(test_case_name);
595
- test_case_infos_.push_back(typed_test_info);
596
- }
597
- return typed_test_info;
598
- }
599
- void RegisterTests() {
600
- for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
601
- it != test_case_infos_.end(); ++it) {
602
- (*it)->RegisterTests();
603
- }
604
- }
605
-
606
- private:
607
- typedef ::std::vector<ParameterizedTestCaseInfoBase*> TestCaseInfoContainer;
608
-
609
- TestCaseInfoContainer test_case_infos_;
610
-
611
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseRegistry);
612
- };
613
-
614
- } // namespace internal
615
- } // namespace testing
616
-
617
- #endif // GTEST_HAS_PARAM_TEST
618
-
619
- #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_