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 //
31 // Tests for Google Test itself. This file verifies that the parameter
32 // generators objects produce correct parameter sequences and that
33 // Google Test runtime instantiates correct tests from those sequences.
34
35 #include "gtest/gtest.h"
36
37 #include <algorithm>
38 #include <iostream>
39 #include <list>
40 #include <sstream>
41 #include <string>
42 #include <vector>
43
44 #include "src/gtest-internal-inl.h" // for UnitTestOptions
45 #include "test/googletest-param-test-test.h"
46
47 using ::std::vector;
48 using ::std::sort;
49
50 using ::testing::AddGlobalTestEnvironment;
51 using ::testing::Bool;
52 using ::testing::Combine;
53 using ::testing::Message;
54 using ::testing::Range;
55 using ::testing::TestWithParam;
56 using ::testing::Values;
57 using ::testing::ValuesIn;
58
59 using ::testing::internal::ParamGenerator;
60 using ::testing::internal::UnitTestOptions;
61
62 // Prints a value to a string.
63 //
64 // FIXME: remove PrintValue() when we move matchers and
65 // EXPECT_THAT() from Google Mock to Google Test. At that time, we
66 // can write EXPECT_THAT(x, Eq(y)) to compare two tuples x and y, as
67 // EXPECT_THAT() and the matchers know how to print tuples.
68 template <typename T>
PrintValue(const T & value)69 ::std::string PrintValue(const T& value) {
70 return testing::PrintToString(value);
71 }
72
73 // Verifies that a sequence generated by the generator and accessed
74 // via the iterator object matches the expected one using Google Test
75 // assertions.
76 template <typename T, size_t N>
VerifyGenerator(const ParamGenerator<T> & generator,const T (& expected_values)[N])77 void VerifyGenerator(const ParamGenerator<T>& generator,
78 const T (&expected_values)[N]) {
79 typename ParamGenerator<T>::iterator it = generator.begin();
80 for (size_t i = 0; i < N; ++i) {
81 ASSERT_FALSE(it == generator.end())
82 << "At element " << i << " when accessing via an iterator "
83 << "created with the copy constructor.\n";
84 // We cannot use EXPECT_EQ() here as the values may be tuples,
85 // which don't support <<.
86 EXPECT_TRUE(expected_values[i] == *it)
87 << "where i is " << i << ", expected_values[i] is "
88 << PrintValue(expected_values[i]) << ", *it is " << PrintValue(*it)
89 << ", and 'it' is an iterator created with the copy constructor.\n";
90 ++it;
91 }
92 EXPECT_TRUE(it == generator.end())
93 << "At the presumed end of sequence when accessing via an iterator "
94 << "created with the copy constructor.\n";
95
96 // Test the iterator assignment. The following lines verify that
97 // the sequence accessed via an iterator initialized via the
98 // assignment operator (as opposed to a copy constructor) matches
99 // just the same.
100 it = generator.begin();
101 for (size_t i = 0; i < N; ++i) {
102 ASSERT_FALSE(it == generator.end())
103 << "At element " << i << " when accessing via an iterator "
104 << "created with the assignment operator.\n";
105 EXPECT_TRUE(expected_values[i] == *it)
106 << "where i is " << i << ", expected_values[i] is "
107 << PrintValue(expected_values[i]) << ", *it is " << PrintValue(*it)
108 << ", and 'it' is an iterator created with the copy constructor.\n";
109 ++it;
110 }
111 EXPECT_TRUE(it == generator.end())
112 << "At the presumed end of sequence when accessing via an iterator "
113 << "created with the assignment operator.\n";
114 }
115
116 template <typename T>
VerifyGeneratorIsEmpty(const ParamGenerator<T> & generator)117 void VerifyGeneratorIsEmpty(const ParamGenerator<T>& generator) {
118 typename ParamGenerator<T>::iterator it = generator.begin();
119 EXPECT_TRUE(it == generator.end());
120
121 it = generator.begin();
122 EXPECT_TRUE(it == generator.end());
123 }
124
125 // Generator tests. They test that each of the provided generator functions
126 // generates an expected sequence of values. The general test pattern
127 // instantiates a generator using one of the generator functions,
128 // checks the sequence produced by the generator using its iterator API,
129 // and then resets the iterator back to the beginning of the sequence
130 // and checks the sequence again.
131
132 // Tests that iterators produced by generator functions conform to the
133 // ForwardIterator concept.
TEST(IteratorTest,ParamIteratorConformsToForwardIteratorConcept)134 TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {
135 const ParamGenerator<int> gen = Range(0, 10);
136 ParamGenerator<int>::iterator it = gen.begin();
137
138 // Verifies that iterator initialization works as expected.
139 ParamGenerator<int>::iterator it2 = it;
140 EXPECT_TRUE(*it == *it2) << "Initialized iterators must point to the "
141 << "element same as its source points to";
142
143 // Verifies that iterator assignment works as expected.
144 ++it;
145 EXPECT_FALSE(*it == *it2);
146 it2 = it;
147 EXPECT_TRUE(*it == *it2) << "Assigned iterators must point to the "
148 << "element same as its source points to";
149
150 // Verifies that prefix operator++() returns *this.
151 EXPECT_EQ(&it, &(++it)) << "Result of the prefix operator++ must be "
152 << "refer to the original object";
153
154 // Verifies that the result of the postfix operator++ points to the value
155 // pointed to by the original iterator.
156 int original_value = *it; // Have to compute it outside of macro call to be
157 // unaffected by the parameter evaluation order.
158 EXPECT_EQ(original_value, *(it++));
159
160 // Verifies that prefix and postfix operator++() advance an iterator
161 // all the same.
162 it2 = it;
163 ++it;
164 ++it2;
165 EXPECT_TRUE(*it == *it2);
166 }
167
168 // Tests that Range() generates the expected sequence.
TEST(RangeTest,IntRangeWithDefaultStep)169 TEST(RangeTest, IntRangeWithDefaultStep) {
170 const ParamGenerator<int> gen = Range(0, 3);
171 const int expected_values[] = {0, 1, 2};
172 VerifyGenerator(gen, expected_values);
173 }
174
175 // Edge case. Tests that Range() generates the single element sequence
176 // as expected when provided with range limits that are equal.
TEST(RangeTest,IntRangeSingleValue)177 TEST(RangeTest, IntRangeSingleValue) {
178 const ParamGenerator<int> gen = Range(0, 1);
179 const int expected_values[] = {0};
180 VerifyGenerator(gen, expected_values);
181 }
182
183 // Edge case. Tests that Range() with generates empty sequence when
184 // supplied with an empty range.
TEST(RangeTest,IntRangeEmpty)185 TEST(RangeTest, IntRangeEmpty) {
186 const ParamGenerator<int> gen = Range(0, 0);
187 VerifyGeneratorIsEmpty(gen);
188 }
189
190 // Tests that Range() with custom step (greater then one) generates
191 // the expected sequence.
TEST(RangeTest,IntRangeWithCustomStep)192 TEST(RangeTest, IntRangeWithCustomStep) {
193 const ParamGenerator<int> gen = Range(0, 9, 3);
194 const int expected_values[] = {0, 3, 6};
195 VerifyGenerator(gen, expected_values);
196 }
197
198 // Tests that Range() with custom step (greater then one) generates
199 // the expected sequence when the last element does not fall on the
200 // upper range limit. Sequences generated by Range() must not have
201 // elements beyond the range limits.
TEST(RangeTest,IntRangeWithCustomStepOverUpperBound)202 TEST(RangeTest, IntRangeWithCustomStepOverUpperBound) {
203 const ParamGenerator<int> gen = Range(0, 4, 3);
204 const int expected_values[] = {0, 3};
205 VerifyGenerator(gen, expected_values);
206 }
207
208 // Verifies that Range works with user-defined types that define
209 // copy constructor, operator=(), operator+(), and operator<().
210 class DogAdder {
211 public:
DogAdder(const char * a_value)212 explicit DogAdder(const char* a_value) : value_(a_value) {}
DogAdder(const DogAdder & other)213 DogAdder(const DogAdder& other) : value_(other.value_.c_str()) {}
214
operator =(const DogAdder & other)215 DogAdder operator=(const DogAdder& other) {
216 if (this != &other) value_ = other.value_;
217 return *this;
218 }
operator +(const DogAdder & other) const219 DogAdder operator+(const DogAdder& other) const {
220 Message msg;
221 msg << value_.c_str() << other.value_.c_str();
222 return DogAdder(msg.GetString().c_str());
223 }
operator <(const DogAdder & other) const224 bool operator<(const DogAdder& other) const { return value_ < other.value_; }
value() const225 const std::string& value() const { return value_; }
226
227 private:
228 std::string value_;
229 };
230
TEST(RangeTest,WorksWithACustomType)231 TEST(RangeTest, WorksWithACustomType) {
232 const ParamGenerator<DogAdder> gen =
233 Range(DogAdder("cat"), DogAdder("catdogdog"), DogAdder("dog"));
234 ParamGenerator<DogAdder>::iterator it = gen.begin();
235
236 ASSERT_FALSE(it == gen.end());
237 EXPECT_STREQ("cat", it->value().c_str());
238
239 ASSERT_FALSE(++it == gen.end());
240 EXPECT_STREQ("catdog", it->value().c_str());
241
242 EXPECT_TRUE(++it == gen.end());
243 }
244
245 class IntWrapper {
246 public:
IntWrapper(int a_value)247 explicit IntWrapper(int a_value) : value_(a_value) {}
IntWrapper(const IntWrapper & other)248 IntWrapper(const IntWrapper& other) : value_(other.value_) {}
249
operator =(const IntWrapper & other)250 IntWrapper operator=(const IntWrapper& other) {
251 value_ = other.value_;
252 return *this;
253 }
254 // operator+() adds a different type.
operator +(int other) const255 IntWrapper operator+(int other) const { return IntWrapper(value_ + other); }
operator <(const IntWrapper & other) const256 bool operator<(const IntWrapper& other) const {
257 return value_ < other.value_;
258 }
value() const259 int value() const { return value_; }
260
261 private:
262 int value_;
263 };
264
TEST(RangeTest,WorksWithACustomTypeWithDifferentIncrementType)265 TEST(RangeTest, WorksWithACustomTypeWithDifferentIncrementType) {
266 const ParamGenerator<IntWrapper> gen = Range(IntWrapper(0), IntWrapper(2));
267 ParamGenerator<IntWrapper>::iterator it = gen.begin();
268
269 ASSERT_FALSE(it == gen.end());
270 EXPECT_EQ(0, it->value());
271
272 ASSERT_FALSE(++it == gen.end());
273 EXPECT_EQ(1, it->value());
274
275 EXPECT_TRUE(++it == gen.end());
276 }
277
278 // Tests that ValuesIn() with an array parameter generates
279 // the expected sequence.
TEST(ValuesInTest,ValuesInArray)280 TEST(ValuesInTest, ValuesInArray) {
281 int array[] = {3, 5, 8};
282 const ParamGenerator<int> gen = ValuesIn(array);
283 VerifyGenerator(gen, array);
284 }
285
286 // Tests that ValuesIn() with a const array parameter generates
287 // the expected sequence.
TEST(ValuesInTest,ValuesInConstArray)288 TEST(ValuesInTest, ValuesInConstArray) {
289 const int array[] = {3, 5, 8};
290 const ParamGenerator<int> gen = ValuesIn(array);
291 VerifyGenerator(gen, array);
292 }
293
294 // Edge case. Tests that ValuesIn() with an array parameter containing a
295 // single element generates the single element sequence.
TEST(ValuesInTest,ValuesInSingleElementArray)296 TEST(ValuesInTest, ValuesInSingleElementArray) {
297 int array[] = {42};
298 const ParamGenerator<int> gen = ValuesIn(array);
299 VerifyGenerator(gen, array);
300 }
301
302 // Tests that ValuesIn() generates the expected sequence for an STL
303 // container (vector).
TEST(ValuesInTest,ValuesInVector)304 TEST(ValuesInTest, ValuesInVector) {
305 typedef ::std::vector<int> ContainerType;
306 ContainerType values;
307 values.push_back(3);
308 values.push_back(5);
309 values.push_back(8);
310 const ParamGenerator<int> gen = ValuesIn(values);
311
312 const int expected_values[] = {3, 5, 8};
313 VerifyGenerator(gen, expected_values);
314 }
315
316 // Tests that ValuesIn() generates the expected sequence.
TEST(ValuesInTest,ValuesInIteratorRange)317 TEST(ValuesInTest, ValuesInIteratorRange) {
318 typedef ::std::vector<int> ContainerType;
319 ContainerType values;
320 values.push_back(3);
321 values.push_back(5);
322 values.push_back(8);
323 const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
324
325 const int expected_values[] = {3, 5, 8};
326 VerifyGenerator(gen, expected_values);
327 }
328
329 // Edge case. Tests that ValuesIn() provided with an iterator range specifying a
330 // single value generates a single-element sequence.
TEST(ValuesInTest,ValuesInSingleElementIteratorRange)331 TEST(ValuesInTest, ValuesInSingleElementIteratorRange) {
332 typedef ::std::vector<int> ContainerType;
333 ContainerType values;
334 values.push_back(42);
335 const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
336
337 const int expected_values[] = {42};
338 VerifyGenerator(gen, expected_values);
339 }
340
341 // Edge case. Tests that ValuesIn() provided with an empty iterator range
342 // generates an empty sequence.
TEST(ValuesInTest,ValuesInEmptyIteratorRange)343 TEST(ValuesInTest, ValuesInEmptyIteratorRange) {
344 typedef ::std::vector<int> ContainerType;
345 ContainerType values;
346 const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
347
348 VerifyGeneratorIsEmpty(gen);
349 }
350
351 // Tests that the Values() generates the expected sequence.
TEST(ValuesTest,ValuesWorks)352 TEST(ValuesTest, ValuesWorks) {
353 const ParamGenerator<int> gen = Values(3, 5, 8);
354
355 const int expected_values[] = {3, 5, 8};
356 VerifyGenerator(gen, expected_values);
357 }
358
359 // Tests that Values() generates the expected sequences from elements of
360 // different types convertible to ParamGenerator's parameter type.
TEST(ValuesTest,ValuesWorksForValuesOfCompatibleTypes)361 TEST(ValuesTest, ValuesWorksForValuesOfCompatibleTypes) {
362 const ParamGenerator<double> gen = Values(3, 5.0f, 8.0);
363
364 const double expected_values[] = {3.0, 5.0, 8.0};
365 VerifyGenerator(gen, expected_values);
366 }
367
TEST(ValuesTest,ValuesWorksForMaxLengthList)368 TEST(ValuesTest, ValuesWorksForMaxLengthList) {
369 const ParamGenerator<int> gen =
370 Values(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150,
371 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280,
372 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410,
373 420, 430, 440, 450, 460, 470, 480, 490, 500);
374
375 const int expected_values[] = {
376 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130,
377 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260,
378 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390,
379 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500};
380 VerifyGenerator(gen, expected_values);
381 }
382
383 // Edge case test. Tests that single-parameter Values() generates the sequence
384 // with the single value.
TEST(ValuesTest,ValuesWithSingleParameter)385 TEST(ValuesTest, ValuesWithSingleParameter) {
386 const ParamGenerator<int> gen = Values(42);
387
388 const int expected_values[] = {42};
389 VerifyGenerator(gen, expected_values);
390 }
391
392 // Tests that Bool() generates sequence (false, true).
TEST(BoolTest,BoolWorks)393 TEST(BoolTest, BoolWorks) {
394 const ParamGenerator<bool> gen = Bool();
395
396 const bool expected_values[] = {false, true};
397 VerifyGenerator(gen, expected_values);
398 }
399
400 // Tests that Combine() with two parameters generates the expected sequence.
TEST(CombineTest,CombineWithTwoParameters)401 TEST(CombineTest, CombineWithTwoParameters) {
402 const char* foo = "foo";
403 const char* bar = "bar";
404 const ParamGenerator<std::tuple<const char*, int> > gen =
405 Combine(Values(foo, bar), Values(3, 4));
406
407 std::tuple<const char*, int> expected_values[] = {
408 std::make_tuple(foo, 3), std::make_tuple(foo, 4), std::make_tuple(bar, 3),
409 std::make_tuple(bar, 4)};
410 VerifyGenerator(gen, expected_values);
411 }
412
413 // Tests that Combine() with three parameters generates the expected sequence.
TEST(CombineTest,CombineWithThreeParameters)414 TEST(CombineTest, CombineWithThreeParameters) {
415 const ParamGenerator<std::tuple<int, int, int> > gen =
416 Combine(Values(0, 1), Values(3, 4), Values(5, 6));
417 std::tuple<int, int, int> expected_values[] = {
418 std::make_tuple(0, 3, 5), std::make_tuple(0, 3, 6),
419 std::make_tuple(0, 4, 5), std::make_tuple(0, 4, 6),
420 std::make_tuple(1, 3, 5), std::make_tuple(1, 3, 6),
421 std::make_tuple(1, 4, 5), std::make_tuple(1, 4, 6)};
422 VerifyGenerator(gen, expected_values);
423 }
424
425 // Tests that the Combine() with the first parameter generating a single value
426 // sequence generates a sequence with the number of elements equal to the
427 // number of elements in the sequence generated by the second parameter.
TEST(CombineTest,CombineWithFirstParameterSingleValue)428 TEST(CombineTest, CombineWithFirstParameterSingleValue) {
429 const ParamGenerator<std::tuple<int, int> > gen =
430 Combine(Values(42), Values(0, 1));
431
432 std::tuple<int, int> expected_values[] = {std::make_tuple(42, 0),
433 std::make_tuple(42, 1)};
434 VerifyGenerator(gen, expected_values);
435 }
436
437 // Tests that the Combine() with the second parameter generating a single value
438 // sequence generates a sequence with the number of elements equal to the
439 // number of elements in the sequence generated by the first parameter.
TEST(CombineTest,CombineWithSecondParameterSingleValue)440 TEST(CombineTest, CombineWithSecondParameterSingleValue) {
441 const ParamGenerator<std::tuple<int, int> > gen =
442 Combine(Values(0, 1), Values(42));
443
444 std::tuple<int, int> expected_values[] = {std::make_tuple(0, 42),
445 std::make_tuple(1, 42)};
446 VerifyGenerator(gen, expected_values);
447 }
448
449 // Tests that when the first parameter produces an empty sequence,
450 // Combine() produces an empty sequence, too.
TEST(CombineTest,CombineWithFirstParameterEmptyRange)451 TEST(CombineTest, CombineWithFirstParameterEmptyRange) {
452 const ParamGenerator<std::tuple<int, int> > gen =
453 Combine(Range(0, 0), Values(0, 1));
454 VerifyGeneratorIsEmpty(gen);
455 }
456
457 // Tests that when the second parameter produces an empty sequence,
458 // Combine() produces an empty sequence, too.
TEST(CombineTest,CombineWithSecondParameterEmptyRange)459 TEST(CombineTest, CombineWithSecondParameterEmptyRange) {
460 const ParamGenerator<std::tuple<int, int> > gen =
461 Combine(Values(0, 1), Range(1, 1));
462 VerifyGeneratorIsEmpty(gen);
463 }
464
465 // Edge case. Tests that combine works with the maximum number
466 // of parameters supported by Google Test (currently 10).
TEST(CombineTest,CombineWithMaxNumberOfParameters)467 TEST(CombineTest, CombineWithMaxNumberOfParameters) {
468 const char* foo = "foo";
469 const char* bar = "bar";
470 const ParamGenerator<
471 std::tuple<const char*, int, int, int, int, int, int, int, int, int> >
472 gen =
473 Combine(Values(foo, bar), Values(1), Values(2), Values(3), Values(4),
474 Values(5), Values(6), Values(7), Values(8), Values(9));
475
476 std::tuple<const char*, int, int, int, int, int, int, int, int, int>
477 expected_values[] = {std::make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),
478 std::make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};
479 VerifyGenerator(gen, expected_values);
480 }
481
482 class NonDefaultConstructAssignString {
483 public:
NonDefaultConstructAssignString(const std::string & s)484 NonDefaultConstructAssignString(const std::string& s) : str_(s) {}
485
str() const486 const std::string& str() const { return str_; }
487
488 private:
489 std::string str_;
490
491 // Not default constructible
492 NonDefaultConstructAssignString();
493 // Not assignable
494 void operator=(const NonDefaultConstructAssignString&);
495 };
496
TEST(CombineTest,NonDefaultConstructAssign)497 TEST(CombineTest, NonDefaultConstructAssign) {
498 const ParamGenerator<std::tuple<int, NonDefaultConstructAssignString> > gen =
499 Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"),
500 NonDefaultConstructAssignString("B")));
501
502 ParamGenerator<std::tuple<int, NonDefaultConstructAssignString> >::iterator
503 it = gen.begin();
504
505 EXPECT_EQ(0, std::get<0>(*it));
506 EXPECT_EQ("A", std::get<1>(*it).str());
507 ++it;
508
509 EXPECT_EQ(0, std::get<0>(*it));
510 EXPECT_EQ("B", std::get<1>(*it).str());
511 ++it;
512
513 EXPECT_EQ(1, std::get<0>(*it));
514 EXPECT_EQ("A", std::get<1>(*it).str());
515 ++it;
516
517 EXPECT_EQ(1, std::get<0>(*it));
518 EXPECT_EQ("B", std::get<1>(*it).str());
519 ++it;
520
521 EXPECT_TRUE(it == gen.end());
522 }
523
524 // Tests that an generator produces correct sequence after being
525 // assigned from another generator.
TEST(ParamGeneratorTest,AssignmentWorks)526 TEST(ParamGeneratorTest, AssignmentWorks) {
527 ParamGenerator<int> gen = Values(1, 2);
528 const ParamGenerator<int> gen2 = Values(3, 4);
529 gen = gen2;
530
531 const int expected_values[] = {3, 4};
532 VerifyGenerator(gen, expected_values);
533 }
534
535 // This test verifies that the tests are expanded and run as specified:
536 // one test per element from the sequence produced by the generator
537 // specified in INSTANTIATE_TEST_SUITE_P. It also verifies that the test's
538 // fixture constructor, SetUp(), and TearDown() have run and have been
539 // supplied with the correct parameters.
540
541 // The use of environment object allows detection of the case where no test
542 // case functionality is run at all. In this case TearDownTestSuite will not
543 // be able to detect missing tests, naturally.
544 template <int kExpectedCalls>
545 class TestGenerationEnvironment : public ::testing::Environment {
546 public:
Instance()547 static TestGenerationEnvironment* Instance() {
548 static TestGenerationEnvironment* instance = new TestGenerationEnvironment;
549 return instance;
550 }
551
FixtureConstructorExecuted()552 void FixtureConstructorExecuted() { fixture_constructor_count_++; }
SetUpExecuted()553 void SetUpExecuted() { set_up_count_++; }
TearDownExecuted()554 void TearDownExecuted() { tear_down_count_++; }
TestBodyExecuted()555 void TestBodyExecuted() { test_body_count_++; }
556
TearDown()557 void TearDown() override {
558 // If all MultipleTestGenerationTest tests have been de-selected
559 // by the filter flag, the following checks make no sense.
560 bool perform_check = false;
561
562 for (int i = 0; i < kExpectedCalls; ++i) {
563 Message msg;
564 msg << "TestsExpandedAndRun/" << i;
565 if (UnitTestOptions::FilterMatchesTest(
566 "TestExpansionModule/MultipleTestGenerationTest",
567 msg.GetString().c_str())) {
568 perform_check = true;
569 }
570 }
571 if (perform_check) {
572 EXPECT_EQ(kExpectedCalls, fixture_constructor_count_)
573 << "Fixture constructor of ParamTestGenerationTest test case "
574 << "has not been run as expected.";
575 EXPECT_EQ(kExpectedCalls, set_up_count_)
576 << "Fixture SetUp method of ParamTestGenerationTest test case "
577 << "has not been run as expected.";
578 EXPECT_EQ(kExpectedCalls, tear_down_count_)
579 << "Fixture TearDown method of ParamTestGenerationTest test case "
580 << "has not been run as expected.";
581 EXPECT_EQ(kExpectedCalls, test_body_count_)
582 << "Test in ParamTestGenerationTest test case "
583 << "has not been run as expected.";
584 }
585 }
586
587 private:
TestGenerationEnvironment()588 TestGenerationEnvironment()
589 : fixture_constructor_count_(0),
590 set_up_count_(0),
591 tear_down_count_(0),
592 test_body_count_(0) {}
593
594 int fixture_constructor_count_;
595 int set_up_count_;
596 int tear_down_count_;
597 int test_body_count_;
598
599 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationEnvironment);
600 };
601
602 const int test_generation_params[] = {36, 42, 72};
603
604 class TestGenerationTest : public TestWithParam<int> {
605 public:
606 enum {
607 PARAMETER_COUNT =
608 sizeof(test_generation_params) / sizeof(test_generation_params[0])
609 };
610
611 typedef TestGenerationEnvironment<PARAMETER_COUNT> Environment;
612
TestGenerationTest()613 TestGenerationTest() {
614 Environment::Instance()->FixtureConstructorExecuted();
615 current_parameter_ = GetParam();
616 }
SetUp()617 void SetUp() override {
618 Environment::Instance()->SetUpExecuted();
619 EXPECT_EQ(current_parameter_, GetParam());
620 }
TearDown()621 void TearDown() override {
622 Environment::Instance()->TearDownExecuted();
623 EXPECT_EQ(current_parameter_, GetParam());
624 }
625
SetUpTestSuite()626 static void SetUpTestSuite() {
627 bool all_tests_in_test_case_selected = true;
628
629 for (int i = 0; i < PARAMETER_COUNT; ++i) {
630 Message test_name;
631 test_name << "TestsExpandedAndRun/" << i;
632 if (!UnitTestOptions::FilterMatchesTest(
633 "TestExpansionModule/MultipleTestGenerationTest",
634 test_name.GetString())) {
635 all_tests_in_test_case_selected = false;
636 }
637 }
638 EXPECT_TRUE(all_tests_in_test_case_selected)
639 << "When running the TestGenerationTest test case all of its tests\n"
640 << "must be selected by the filter flag for the test case to pass.\n"
641 << "If not all of them are enabled, we can't reliably conclude\n"
642 << "that the correct number of tests have been generated.";
643
644 collected_parameters_.clear();
645 }
646
TearDownTestSuite()647 static void TearDownTestSuite() {
648 vector<int> expected_values(test_generation_params,
649 test_generation_params + PARAMETER_COUNT);
650 // Test execution order is not guaranteed by Google Test,
651 // so the order of values in collected_parameters_ can be
652 // different and we have to sort to compare.
653 sort(expected_values.begin(), expected_values.end());
654 sort(collected_parameters_.begin(), collected_parameters_.end());
655
656 EXPECT_TRUE(collected_parameters_ == expected_values);
657 }
658
659 protected:
660 int current_parameter_;
661 static vector<int> collected_parameters_;
662
663 private:
664 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationTest);
665 };
666 vector<int> TestGenerationTest::collected_parameters_;
667
TEST_P(TestGenerationTest,TestsExpandedAndRun)668 TEST_P(TestGenerationTest, TestsExpandedAndRun) {
669 Environment::Instance()->TestBodyExecuted();
670 EXPECT_EQ(current_parameter_, GetParam());
671 collected_parameters_.push_back(GetParam());
672 }
673 INSTANTIATE_TEST_SUITE_P(TestExpansionModule, TestGenerationTest,
674 ValuesIn(test_generation_params));
675
676 // This test verifies that the element sequence (third parameter of
677 // INSTANTIATE_TEST_SUITE_P) is evaluated in InitGoogleTest() and neither at
678 // the call site of INSTANTIATE_TEST_SUITE_P nor in RUN_ALL_TESTS(). For
679 // that, we declare param_value_ to be a static member of
680 // GeneratorEvaluationTest and initialize it to 0. We set it to 1 in
681 // main(), just before invocation of InitGoogleTest(). After calling
682 // InitGoogleTest(), we set the value to 2. If the sequence is evaluated
683 // before or after InitGoogleTest, INSTANTIATE_TEST_SUITE_P will create a
684 // test with parameter other than 1, and the test body will fail the
685 // assertion.
686 class GeneratorEvaluationTest : public TestWithParam<int> {
687 public:
param_value()688 static int param_value() { return param_value_; }
set_param_value(int param_value)689 static void set_param_value(int param_value) { param_value_ = param_value; }
690
691 private:
692 static int param_value_;
693 };
694 int GeneratorEvaluationTest::param_value_ = 0;
695
TEST_P(GeneratorEvaluationTest,GeneratorsEvaluatedInMain)696 TEST_P(GeneratorEvaluationTest, GeneratorsEvaluatedInMain) {
697 EXPECT_EQ(1, GetParam());
698 }
699 INSTANTIATE_TEST_SUITE_P(GenEvalModule, GeneratorEvaluationTest,
700 Values(GeneratorEvaluationTest::param_value()));
701
702 // Tests that generators defined in a different translation unit are
703 // functional. Generator extern_gen is defined in gtest-param-test_test2.cc.
704 extern ParamGenerator<int> extern_gen;
705 class ExternalGeneratorTest : public TestWithParam<int> {};
TEST_P(ExternalGeneratorTest,ExternalGenerator)706 TEST_P(ExternalGeneratorTest, ExternalGenerator) {
707 // Sequence produced by extern_gen contains only a single value
708 // which we verify here.
709 EXPECT_EQ(GetParam(), 33);
710 }
711 INSTANTIATE_TEST_SUITE_P(ExternalGeneratorModule, ExternalGeneratorTest,
712 extern_gen);
713
714 // Tests that a parameterized test case can be defined in one translation
715 // unit and instantiated in another. This test will be instantiated in
716 // gtest-param-test_test2.cc. ExternalInstantiationTest fixture class is
717 // defined in gtest-param-test_test.h.
TEST_P(ExternalInstantiationTest,IsMultipleOf33)718 TEST_P(ExternalInstantiationTest, IsMultipleOf33) {
719 EXPECT_EQ(0, GetParam() % 33);
720 }
721
722 // Tests that a parameterized test case can be instantiated with multiple
723 // generators.
724 class MultipleInstantiationTest : public TestWithParam<int> {};
TEST_P(MultipleInstantiationTest,AllowsMultipleInstances)725 TEST_P(MultipleInstantiationTest, AllowsMultipleInstances) {}
726 INSTANTIATE_TEST_SUITE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));
727 INSTANTIATE_TEST_SUITE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));
728
729 // Tests that a parameterized test case can be instantiated
730 // in multiple translation units. This test will be instantiated
731 // here and in gtest-param-test_test2.cc.
732 // InstantiationInMultipleTranslationUnitsTest fixture class
733 // is defined in gtest-param-test_test.h.
TEST_P(InstantiationInMultipleTranslationUnitsTest,IsMultipleOf42)734 TEST_P(InstantiationInMultipleTranslationUnitsTest, IsMultipleOf42) {
735 EXPECT_EQ(0, GetParam() % 42);
736 }
737 INSTANTIATE_TEST_SUITE_P(Sequence1, InstantiationInMultipleTranslationUnitsTest,
738 Values(42, 42 * 2));
739
740 // Tests that each iteration of parameterized test runs in a separate test
741 // object.
742 class SeparateInstanceTest : public TestWithParam<int> {
743 public:
SeparateInstanceTest()744 SeparateInstanceTest() : count_(0) {}
745
TearDownTestSuite()746 static void TearDownTestSuite() {
747 EXPECT_GE(global_count_, 2)
748 << "If some (but not all) SeparateInstanceTest tests have been "
749 << "filtered out this test will fail. Make sure that all "
750 << "GeneratorEvaluationTest are selected or de-selected together "
751 << "by the test filter.";
752 }
753
754 protected:
755 int count_;
756 static int global_count_;
757 };
758 int SeparateInstanceTest::global_count_ = 0;
759
TEST_P(SeparateInstanceTest,TestsRunInSeparateInstances)760 TEST_P(SeparateInstanceTest, TestsRunInSeparateInstances) {
761 EXPECT_EQ(0, count_++);
762 global_count_++;
763 }
764 INSTANTIATE_TEST_SUITE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));
765
766 // Tests that all instantiations of a test have named appropriately. Test
767 // defined with TEST_P(TestSuiteName, TestName) and instantiated with
768 // INSTANTIATE_TEST_SUITE_P(SequenceName, TestSuiteName, generator) must be
769 // named SequenceName/TestSuiteName.TestName/i, where i is the 0-based index of
770 // the sequence element used to instantiate the test.
771 class NamingTest : public TestWithParam<int> {};
772
TEST_P(NamingTest,TestsReportCorrectNamesAndParameters)773 TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
774 const ::testing::TestInfo* const test_info =
775 ::testing::UnitTest::GetInstance()->current_test_info();
776
777 EXPECT_STREQ("ZeroToFiveSequence/NamingTest", test_info->test_suite_name());
778
779 Message index_stream;
780 index_stream << "TestsReportCorrectNamesAndParameters/" << GetParam();
781 EXPECT_STREQ(index_stream.GetString().c_str(), test_info->name());
782
783 EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
784 }
785
786 INSTANTIATE_TEST_SUITE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
787
788 // Tests that macros in test names are expanded correctly.
789 class MacroNamingTest : public TestWithParam<int> {};
790
791 #define PREFIX_WITH_FOO(test_name) Foo##test_name
792 #define PREFIX_WITH_MACRO(test_name) Macro##test_name
793
TEST_P(PREFIX_WITH_MACRO (NamingTest),PREFIX_WITH_FOO (SomeTestName))794 TEST_P(PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName)) {
795 const ::testing::TestInfo* const test_info =
796 ::testing::UnitTest::GetInstance()->current_test_info();
797
798 EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_suite_name());
799 EXPECT_STREQ("FooSomeTestName", test_info->name());
800 }
801
802 INSTANTIATE_TEST_SUITE_P(FortyTwo, MacroNamingTest, Values(42));
803
804 // Tests the same thing for non-parametrized tests.
805 class MacroNamingTestNonParametrized : public ::testing::Test {};
806
TEST_F(PREFIX_WITH_MACRO (NamingTestNonParametrized),PREFIX_WITH_FOO (SomeTestName))807 TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized),
808 PREFIX_WITH_FOO(SomeTestName)) {
809 const ::testing::TestInfo* const test_info =
810 ::testing::UnitTest::GetInstance()->current_test_info();
811
812 EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_suite_name());
813 EXPECT_STREQ("FooSomeTestName", test_info->name());
814 }
815
816 // Tests that user supplied custom parameter names are working correctly.
817 // Runs the test with a builtin helper method which uses PrintToString,
818 // as well as a custom function and custom functor to ensure all possible
819 // uses work correctly.
820 class CustomFunctorNamingTest : public TestWithParam<std::string> {};
TEST_P(CustomFunctorNamingTest,CustomTestNames)821 TEST_P(CustomFunctorNamingTest, CustomTestNames) {}
822
823 struct CustomParamNameFunctor {
operator ()CustomParamNameFunctor824 std::string operator()(const ::testing::TestParamInfo<std::string>& inf) {
825 return inf.param;
826 }
827 };
828
829 INSTANTIATE_TEST_SUITE_P(CustomParamNameFunctor, CustomFunctorNamingTest,
830 Values(std::string("FunctorName")),
831 CustomParamNameFunctor());
832
833 INSTANTIATE_TEST_SUITE_P(AllAllowedCharacters, CustomFunctorNamingTest,
834 Values("abcdefghijklmnopqrstuvwxyz",
835 "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "01234567890_"),
836 CustomParamNameFunctor());
837
CustomParamNameFunction(const::testing::TestParamInfo<std::string> & inf)838 inline std::string CustomParamNameFunction(
839 const ::testing::TestParamInfo<std::string>& inf) {
840 return inf.param;
841 }
842
843 class CustomFunctionNamingTest : public TestWithParam<std::string> {};
TEST_P(CustomFunctionNamingTest,CustomTestNames)844 TEST_P(CustomFunctionNamingTest, CustomTestNames) {}
845
846 INSTANTIATE_TEST_SUITE_P(CustomParamNameFunction, CustomFunctionNamingTest,
847 Values(std::string("FunctionName")),
848 CustomParamNameFunction);
849
850 INSTANTIATE_TEST_SUITE_P(CustomParamNameFunctionP, CustomFunctionNamingTest,
851 Values(std::string("FunctionNameP")),
852 &CustomParamNameFunction);
853
854 // Test custom naming with a lambda
855
856 class CustomLambdaNamingTest : public TestWithParam<std::string> {};
TEST_P(CustomLambdaNamingTest,CustomTestNames)857 TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
858
859 INSTANTIATE_TEST_SUITE_P(CustomParamNameLambda, CustomLambdaNamingTest,
860 Values(std::string("LambdaName")),
__anonb317ae360202(const ::testing::TestParamInfo<std::string>& inf) 861 [](const ::testing::TestParamInfo<std::string>& inf) {
862 return inf.param;
863 });
864
TEST(CustomNamingTest,CheckNameRegistry)865 TEST(CustomNamingTest, CheckNameRegistry) {
866 ::testing::UnitTest* unit_test = ::testing::UnitTest::GetInstance();
867 std::set<std::string> test_names;
868 for (int suite_num = 0; suite_num < unit_test->total_test_suite_count();
869 ++suite_num) {
870 const ::testing::TestSuite* test_suite = unit_test->GetTestSuite(suite_num);
871 for (int test_num = 0; test_num < test_suite->total_test_count();
872 ++test_num) {
873 const ::testing::TestInfo* test_info = test_suite->GetTestInfo(test_num);
874 test_names.insert(std::string(test_info->name()));
875 }
876 }
877 EXPECT_EQ(1u, test_names.count("CustomTestNames/FunctorName"));
878 EXPECT_EQ(1u, test_names.count("CustomTestNames/FunctionName"));
879 EXPECT_EQ(1u, test_names.count("CustomTestNames/FunctionNameP"));
880 EXPECT_EQ(1u, test_names.count("CustomTestNames/LambdaName"));
881 }
882
883 // Test a numeric name to ensure PrintToStringParamName works correctly.
884
885 class CustomIntegerNamingTest : public TestWithParam<int> {};
886
TEST_P(CustomIntegerNamingTest,TestsReportCorrectNames)887 TEST_P(CustomIntegerNamingTest, TestsReportCorrectNames) {
888 const ::testing::TestInfo* const test_info =
889 ::testing::UnitTest::GetInstance()->current_test_info();
890 Message test_name_stream;
891 test_name_stream << "TestsReportCorrectNames/" << GetParam();
892 EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
893 }
894
895 INSTANTIATE_TEST_SUITE_P(PrintToString, CustomIntegerNamingTest, Range(0, 5),
896 ::testing::PrintToStringParamName());
897
898 // Test a custom struct with PrintToString.
899
900 struct CustomStruct {
CustomStructCustomStruct901 explicit CustomStruct(int value) : x(value) {}
902 int x;
903 };
904
operator <<(std::ostream & stream,const CustomStruct & val)905 std::ostream& operator<<(std::ostream& stream, const CustomStruct& val) {
906 stream << val.x;
907 return stream;
908 }
909
910 class CustomStructNamingTest : public TestWithParam<CustomStruct> {};
911
TEST_P(CustomStructNamingTest,TestsReportCorrectNames)912 TEST_P(CustomStructNamingTest, TestsReportCorrectNames) {
913 const ::testing::TestInfo* const test_info =
914 ::testing::UnitTest::GetInstance()->current_test_info();
915 Message test_name_stream;
916 test_name_stream << "TestsReportCorrectNames/" << GetParam();
917 EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
918 }
919
920 INSTANTIATE_TEST_SUITE_P(PrintToString, CustomStructNamingTest,
921 Values(CustomStruct(0), CustomStruct(1)),
922 ::testing::PrintToStringParamName());
923
924 // Test that using a stateful parameter naming function works as expected.
925
926 struct StatefulNamingFunctor {
StatefulNamingFunctorStatefulNamingFunctor927 StatefulNamingFunctor() : sum(0) {}
operator ()StatefulNamingFunctor928 std::string operator()(const ::testing::TestParamInfo<int>& info) {
929 int value = info.param + sum;
930 sum += info.param;
931 return ::testing::PrintToString(value);
932 }
933 int sum;
934 };
935
936 class StatefulNamingTest : public ::testing::TestWithParam<int> {
937 protected:
StatefulNamingTest()938 StatefulNamingTest() : sum_(0) {}
939 int sum_;
940 };
941
TEST_P(StatefulNamingTest,TestsReportCorrectNames)942 TEST_P(StatefulNamingTest, TestsReportCorrectNames) {
943 const ::testing::TestInfo* const test_info =
944 ::testing::UnitTest::GetInstance()->current_test_info();
945 sum_ += GetParam();
946 Message test_name_stream;
947 test_name_stream << "TestsReportCorrectNames/" << sum_;
948 EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
949 }
950
951 INSTANTIATE_TEST_SUITE_P(StatefulNamingFunctor, StatefulNamingTest, Range(0, 5),
952 StatefulNamingFunctor());
953
954 // Class that cannot be streamed into an ostream. It needs to be copyable
955 // (and, in case of MSVC, also assignable) in order to be a test parameter
956 // type. Its default copy constructor and assignment operator do exactly
957 // what we need.
958 class Unstreamable {
959 public:
Unstreamable(int value)960 explicit Unstreamable(int value) : value_(value) {}
961 // -Wunused-private-field: dummy accessor for `value_`.
dummy_value() const962 const int& dummy_value() const { return value_; }
963
964 private:
965 int value_;
966 };
967
968 class CommentTest : public TestWithParam<Unstreamable> {};
969
TEST_P(CommentTest,TestsCorrectlyReportUnstreamableParams)970 TEST_P(CommentTest, TestsCorrectlyReportUnstreamableParams) {
971 const ::testing::TestInfo* const test_info =
972 ::testing::UnitTest::GetInstance()->current_test_info();
973
974 EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
975 }
976
977 INSTANTIATE_TEST_SUITE_P(InstantiationWithComments, CommentTest,
978 Values(Unstreamable(1)));
979
980 // Verify that we can create a hierarchy of test fixtures, where the base
981 // class fixture is not parameterized and the derived class is. In this case
982 // ParameterizedDerivedTest inherits from NonParameterizedBaseTest. We
983 // perform simple tests on both.
984 class NonParameterizedBaseTest : public ::testing::Test {
985 public:
NonParameterizedBaseTest()986 NonParameterizedBaseTest() : n_(17) {}
987
988 protected:
989 int n_;
990 };
991
992 class ParameterizedDerivedTest : public NonParameterizedBaseTest,
993 public ::testing::WithParamInterface<int> {
994 protected:
ParameterizedDerivedTest()995 ParameterizedDerivedTest() : count_(0) {}
996 int count_;
997 static int global_count_;
998 };
999
1000 int ParameterizedDerivedTest::global_count_ = 0;
1001
TEST_F(NonParameterizedBaseTest,FixtureIsInitialized)1002 TEST_F(NonParameterizedBaseTest, FixtureIsInitialized) { EXPECT_EQ(17, n_); }
1003
TEST_P(ParameterizedDerivedTest,SeesSequence)1004 TEST_P(ParameterizedDerivedTest, SeesSequence) {
1005 EXPECT_EQ(17, n_);
1006 EXPECT_EQ(0, count_++);
1007 EXPECT_EQ(GetParam(), global_count_++);
1008 }
1009
1010 class ParameterizedDeathTest : public ::testing::TestWithParam<int> {};
1011
TEST_F(ParameterizedDeathTest,GetParamDiesFromTestF)1012 TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
1013 EXPECT_DEATH_IF_SUPPORTED(GetParam(), ".* value-parameterized test .*");
1014 }
1015
1016 INSTANTIATE_TEST_SUITE_P(RangeZeroToFive, ParameterizedDerivedTest,
1017 Range(0, 5));
1018
1019 // Tests param generator working with Enums
1020 enum MyEnums {
1021 ENUM1 = 1,
1022 ENUM2 = 3,
1023 ENUM3 = 8,
1024 };
1025
1026 class MyEnumTest : public testing::TestWithParam<MyEnums> {};
1027
TEST_P(MyEnumTest,ChecksParamMoreThanZero)1028 TEST_P(MyEnumTest, ChecksParamMoreThanZero) { EXPECT_GE(10, GetParam()); }
1029 INSTANTIATE_TEST_SUITE_P(MyEnumTests, MyEnumTest,
1030 ::testing::Values(ENUM1, ENUM2, 0));
1031
main(int argc,char ** argv)1032 int main(int argc, char** argv) {
1033 // Used in TestGenerationTest test suite.
1034 AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
1035 // Used in GeneratorEvaluationTest test suite. Tests that the updated value
1036 // will be picked up for instantiating tests in GeneratorEvaluationTest.
1037 GeneratorEvaluationTest::set_param_value(1);
1038
1039 ::testing::InitGoogleTest(&argc, argv);
1040
1041 // Used in GeneratorEvaluationTest test suite. Tests that value updated
1042 // here will NOT be used for instantiating tests in
1043 // GeneratorEvaluationTest.
1044 GeneratorEvaluationTest::set_param_value(2);
1045
1046 return RUN_ALL_TESTS();
1047 }
1048