1f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Copyright 2008, Google Inc.
2f904a612d9444ab36c07a8e619c113432e046f49vladlosev// All rights reserved.
3f904a612d9444ab36c07a8e619c113432e046f49vladlosev//
4f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Redistribution and use in source and binary forms, with or without
5f904a612d9444ab36c07a8e619c113432e046f49vladlosev// modification, are permitted provided that the following conditions are
6f904a612d9444ab36c07a8e619c113432e046f49vladlosev// met:
7f904a612d9444ab36c07a8e619c113432e046f49vladlosev//
8f904a612d9444ab36c07a8e619c113432e046f49vladlosev//     * Redistributions of source code must retain the above copyright
9f904a612d9444ab36c07a8e619c113432e046f49vladlosev// notice, this list of conditions and the following disclaimer.
10f904a612d9444ab36c07a8e619c113432e046f49vladlosev//     * Redistributions in binary form must reproduce the above
11f904a612d9444ab36c07a8e619c113432e046f49vladlosev// copyright notice, this list of conditions and the following disclaimer
12f904a612d9444ab36c07a8e619c113432e046f49vladlosev// in the documentation and/or other materials provided with the
13f904a612d9444ab36c07a8e619c113432e046f49vladlosev// distribution.
14f904a612d9444ab36c07a8e619c113432e046f49vladlosev//     * Neither the name of Google Inc. nor the names of its
15f904a612d9444ab36c07a8e619c113432e046f49vladlosev// contributors may be used to endorse or promote products derived from
16f904a612d9444ab36c07a8e619c113432e046f49vladlosev// this software without specific prior written permission.
17f904a612d9444ab36c07a8e619c113432e046f49vladlosev//
18f904a612d9444ab36c07a8e619c113432e046f49vladlosev// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19f904a612d9444ab36c07a8e619c113432e046f49vladlosev// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20f904a612d9444ab36c07a8e619c113432e046f49vladlosev// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21f904a612d9444ab36c07a8e619c113432e046f49vladlosev// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22f904a612d9444ab36c07a8e619c113432e046f49vladlosev// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23f904a612d9444ab36c07a8e619c113432e046f49vladlosev// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24f904a612d9444ab36c07a8e619c113432e046f49vladlosev// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25f904a612d9444ab36c07a8e619c113432e046f49vladlosev// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26f904a612d9444ab36c07a8e619c113432e046f49vladlosev// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27f904a612d9444ab36c07a8e619c113432e046f49vladlosev// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28f904a612d9444ab36c07a8e619c113432e046f49vladlosev// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29f904a612d9444ab36c07a8e619c113432e046f49vladlosev//
30f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Author: vladl@google.com (Vlad Losev)
31f904a612d9444ab36c07a8e619c113432e046f49vladlosev//
32f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests for Google Test itself. This file verifies that the parameter
33f904a612d9444ab36c07a8e619c113432e046f49vladlosev// generators objects produce correct parameter sequences and that
34f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Google Test runtime instantiates correct tests from those sequences.
35f904a612d9444ab36c07a8e619c113432e046f49vladlosev
362620c79810d4741922e9fa89050c0af564994f24zhanyong.wan#include "gtest/gtest.h"
37f904a612d9444ab36c07a8e619c113432e046f49vladlosev
384cd62602913a032a7aec091d4c8055ff9af95e37zhanyong.wan#if GTEST_HAS_PARAM_TEST
39f904a612d9444ab36c07a8e619c113432e046f49vladlosev
40733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include <algorithm>
41733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include <iostream>
42733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include <list>
43733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include <sstream>
44733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include <string>
45733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include <vector>
46f904a612d9444ab36c07a8e619c113432e046f49vladlosev
47f904a612d9444ab36c07a8e619c113432e046f49vladlosev// To include gtest-internal-inl.h.
48733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# define GTEST_IMPLEMENTATION_ 1
49733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include "src/gtest-internal-inl.h"  // for UnitTestOptions
50733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# undef GTEST_IMPLEMENTATION_
51f904a612d9444ab36c07a8e619c113432e046f49vladlosev
52733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include "test/gtest-param-test_test.h"
53f904a612d9444ab36c07a8e619c113432e046f49vladlosev
54f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::std::vector;
55f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::std::sort;
56f904a612d9444ab36c07a8e619c113432e046f49vladlosev
57f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::AddGlobalTestEnvironment;
58f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::Bool;
59f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::Message;
60f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::Range;
61f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::TestWithParam;
62f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::Values;
63f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::ValuesIn;
64f904a612d9444ab36c07a8e619c113432e046f49vladlosev
65733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# if GTEST_HAS_COMBINE
66f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::Combine;
67e735d74bc537869af877dfc90c171dc140495c11kosak@google.comusing ::testing::get;
68e735d74bc537869af877dfc90c171dc140495c11kosak@google.comusing ::testing::make_tuple;
69e735d74bc537869af877dfc90c171dc140495c11kosak@google.comusing ::testing::tuple;
70733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# endif  // GTEST_HAS_COMBINE
71f904a612d9444ab36c07a8e619c113432e046f49vladlosev
72f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::internal::ParamGenerator;
73f904a612d9444ab36c07a8e619c113432e046f49vladlosevusing ::testing::internal::UnitTestOptions;
74f904a612d9444ab36c07a8e619c113432e046f49vladlosev
756851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// Prints a value to a string.
766851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan//
776851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// TODO(wan@google.com): remove PrintValue() when we move matchers and
786851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// EXPECT_THAT() from Google Mock to Google Test.  At that time, we
796851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// can write EXPECT_THAT(x, Eq(y)) to compare two tuples x and y, as
806851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// EXPECT_THAT() and the matchers know how to print tuples.
816851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wantemplate <typename T>
826851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan::std::string PrintValue(const T& value) {
836851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  ::std::stringstream stream;
846851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  stream << value;
856851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  return stream.str();
866851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan}
876851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan
88733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# if GTEST_HAS_COMBINE
896851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan
906851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// These overloads allow printing tuples in our tests.  We cannot
916851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// define an operator<< for tuples, as that definition needs to be in
926851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// the std namespace in order to be picked up by Google Test via
936851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// Argument-Dependent Lookup, yet defining anything in the std
946851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan// namespace in non-STL code is undefined behavior.
956851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan
966851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wantemplate <typename T1, typename T2>
976851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan::std::string PrintValue(const tuple<T1, T2>& value) {
986851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  ::std::stringstream stream;
996851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  stream << "(" << get<0>(value) << ", " << get<1>(value) << ")";
1006851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  return stream.str();
1016851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan}
1026851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan
1036851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wantemplate <typename T1, typename T2, typename T3>
1046851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan::std::string PrintValue(const tuple<T1, T2, T3>& value) {
1056851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  ::std::stringstream stream;
1066851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  stream << "(" << get<0>(value) << ", " << get<1>(value)
1076851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan         << ", "<< get<2>(value) << ")";
1086851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  return stream.str();
1096851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan}
1106851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan
1116851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wantemplate <typename T1, typename T2, typename T3, typename T4, typename T5,
1126851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan          typename T6, typename T7, typename T8, typename T9, typename T10>
1136851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan::std::string PrintValue(
1146851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan    const tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) {
1156851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  ::std::stringstream stream;
1166851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  stream << "(" << get<0>(value) << ", " << get<1>(value)
1176851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan         << ", "<< get<2>(value) << ", " << get<3>(value)
1186851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan         << ", "<< get<4>(value) << ", " << get<5>(value)
1196851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan         << ", "<< get<6>(value) << ", " << get<7>(value)
1206851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan         << ", "<< get<8>(value) << ", " << get<9>(value) << ")";
1216851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan  return stream.str();
1226851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan}
1236851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan
124733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# endif  // GTEST_HAS_COMBINE
1256851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan
126f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Verifies that a sequence generated by the generator and accessed
127f904a612d9444ab36c07a8e619c113432e046f49vladlosev// via the iterator object matches the expected one using Google Test
128f904a612d9444ab36c07a8e619c113432e046f49vladlosev// assertions.
129f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <typename T, size_t N>
130f904a612d9444ab36c07a8e619c113432e046f49vladlosevvoid VerifyGenerator(const ParamGenerator<T>& generator,
131f904a612d9444ab36c07a8e619c113432e046f49vladlosev                     const T (&expected_values)[N]) {
132f904a612d9444ab36c07a8e619c113432e046f49vladlosev  typename ParamGenerator<T>::iterator it = generator.begin();
133f904a612d9444ab36c07a8e619c113432e046f49vladlosev  for (size_t i = 0; i < N; ++i) {
134f904a612d9444ab36c07a8e619c113432e046f49vladlosev    ASSERT_FALSE(it == generator.end())
135f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "At element " << i << " when accessing via an iterator "
1366851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << "created with the copy constructor.\n";
1376851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan    // We cannot use EXPECT_EQ() here as the values may be tuples,
1386851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan    // which don't support <<.
1396851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan    EXPECT_TRUE(expected_values[i] == *it)
1406851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << "where i is " << i
1416851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << ", expected_values[i] is " << PrintValue(expected_values[i])
1426851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << ", *it is " << PrintValue(*it)
1436851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << ", and 'it' is an iterator created with the copy constructor.\n";
144f904a612d9444ab36c07a8e619c113432e046f49vladlosev    it++;
145f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
146f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(it == generator.end())
147f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "At the presumed end of sequence when accessing via an iterator "
1486851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << "created with the copy constructor.\n";
149f904a612d9444ab36c07a8e619c113432e046f49vladlosev
150f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // Test the iterator assignment. The following lines verify that
151f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // the sequence accessed via an iterator initialized via the
152f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // assignment operator (as opposed to a copy constructor) matches
153f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // just the same.
154f904a612d9444ab36c07a8e619c113432e046f49vladlosev  it = generator.begin();
155f904a612d9444ab36c07a8e619c113432e046f49vladlosev  for (size_t i = 0; i < N; ++i) {
156f904a612d9444ab36c07a8e619c113432e046f49vladlosev    ASSERT_FALSE(it == generator.end())
157f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "At element " << i << " when accessing via an iterator "
1586851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << "created with the assignment operator.\n";
1596851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan    EXPECT_TRUE(expected_values[i] == *it)
1606851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << "where i is " << i
1616851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << ", expected_values[i] is " << PrintValue(expected_values[i])
1626851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << ", *it is " << PrintValue(*it)
1636851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << ", and 'it' is an iterator created with the copy constructor.\n";
164f904a612d9444ab36c07a8e619c113432e046f49vladlosev    it++;
165f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
166f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(it == generator.end())
167f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "At the presumed end of sequence when accessing via an iterator "
1686851df92502ee6b9b96f008ae66e676f9565fc46zhanyong.wan        << "created with the assignment operator.\n";
169f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
170f904a612d9444ab36c07a8e619c113432e046f49vladlosev
171f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <typename T>
172f904a612d9444ab36c07a8e619c113432e046f49vladlosevvoid VerifyGeneratorIsEmpty(const ParamGenerator<T>& generator) {
173f904a612d9444ab36c07a8e619c113432e046f49vladlosev  typename ParamGenerator<T>::iterator it = generator.begin();
174f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(it == generator.end());
175f904a612d9444ab36c07a8e619c113432e046f49vladlosev
176f904a612d9444ab36c07a8e619c113432e046f49vladlosev  it = generator.begin();
177f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(it == generator.end());
178f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
179f904a612d9444ab36c07a8e619c113432e046f49vladlosev
180f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Generator tests. They test that each of the provided generator functions
181f904a612d9444ab36c07a8e619c113432e046f49vladlosev// generates an expected sequence of values. The general test pattern
182f904a612d9444ab36c07a8e619c113432e046f49vladlosev// instantiates a generator using one of the generator functions,
183f904a612d9444ab36c07a8e619c113432e046f49vladlosev// checks the sequence produced by the generator using its iterator API,
184f904a612d9444ab36c07a8e619c113432e046f49vladlosev// and then resets the iterator back to the beginning of the sequence
185f904a612d9444ab36c07a8e619c113432e046f49vladlosev// and checks the sequence again.
186f904a612d9444ab36c07a8e619c113432e046f49vladlosev
187f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that iterators produced by generator functions conform to the
188f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ForwardIterator concept.
189f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {
190f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Range(0, 10);
191f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ParamGenerator<int>::iterator it = gen.begin();
192f904a612d9444ab36c07a8e619c113432e046f49vladlosev
193f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // Verifies that iterator initialization works as expected.
194f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ParamGenerator<int>::iterator it2 = it;
195f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(*it == *it2) << "Initialized iterators must point to the "
196f904a612d9444ab36c07a8e619c113432e046f49vladlosev                           << "element same as its source points to";
197f904a612d9444ab36c07a8e619c113432e046f49vladlosev
198f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // Verifies that iterator assignment works as expected.
199f904a612d9444ab36c07a8e619c113432e046f49vladlosev  it++;
200f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_FALSE(*it == *it2);
201f904a612d9444ab36c07a8e619c113432e046f49vladlosev  it2 = it;
202f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(*it == *it2) << "Assigned iterators must point to the "
203f904a612d9444ab36c07a8e619c113432e046f49vladlosev                           << "element same as its source points to";
204f904a612d9444ab36c07a8e619c113432e046f49vladlosev
205f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // Verifies that prefix operator++() returns *this.
206f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(&it, &(++it)) << "Result of the prefix operator++ must be "
207f904a612d9444ab36c07a8e619c113432e046f49vladlosev                          << "refer to the original object";
208f904a612d9444ab36c07a8e619c113432e046f49vladlosev
209f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // Verifies that the result of the postfix operator++ points to the value
210f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // pointed to by the original iterator.
211f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int original_value = *it;  // Have to compute it outside of macro call to be
212f904a612d9444ab36c07a8e619c113432e046f49vladlosev                             // unaffected by the parameter evaluation order.
213f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(original_value, *(it++));
214f904a612d9444ab36c07a8e619c113432e046f49vladlosev
215f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // Verifies that prefix and postfix operator++() advance an iterator
216f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // all the same.
217f904a612d9444ab36c07a8e619c113432e046f49vladlosev  it2 = it;
218f904a612d9444ab36c07a8e619c113432e046f49vladlosev  it++;
219f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ++it2;
220f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(*it == *it2);
221f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
222f904a612d9444ab36c07a8e619c113432e046f49vladlosev
223f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that Range() generates the expected sequence.
224f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(RangeTest, IntRangeWithDefaultStep) {
225f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Range(0, 3);
226f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {0, 1, 2};
227f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
228f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
229f904a612d9444ab36c07a8e619c113432e046f49vladlosev
230f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Edge case. Tests that Range() generates the single element sequence
231f904a612d9444ab36c07a8e619c113432e046f49vladlosev// as expected when provided with range limits that are equal.
232f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(RangeTest, IntRangeSingleValue) {
233f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Range(0, 1);
234f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {0};
235f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
236f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
237f904a612d9444ab36c07a8e619c113432e046f49vladlosev
238f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Edge case. Tests that Range() with generates empty sequence when
239f904a612d9444ab36c07a8e619c113432e046f49vladlosev// supplied with an empty range.
240f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(RangeTest, IntRangeEmpty) {
241f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Range(0, 0);
242f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGeneratorIsEmpty(gen);
243f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
244f904a612d9444ab36c07a8e619c113432e046f49vladlosev
245f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that Range() with custom step (greater then one) generates
246f904a612d9444ab36c07a8e619c113432e046f49vladlosev// the expected sequence.
247f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(RangeTest, IntRangeWithCustomStep) {
248f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Range(0, 9, 3);
249f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {0, 3, 6};
250f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
251f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
252f904a612d9444ab36c07a8e619c113432e046f49vladlosev
253f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that Range() with custom step (greater then one) generates
254f904a612d9444ab36c07a8e619c113432e046f49vladlosev// the expected sequence when the last element does not fall on the
255f904a612d9444ab36c07a8e619c113432e046f49vladlosev// upper range limit. Sequences generated by Range() must not have
256f904a612d9444ab36c07a8e619c113432e046f49vladlosev// elements beyond the range limits.
257f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(RangeTest, IntRangeWithCustomStepOverUpperBound) {
258f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Range(0, 4, 3);
259f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {0, 3};
260f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
261f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
262f904a612d9444ab36c07a8e619c113432e046f49vladlosev
263f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Verifies that Range works with user-defined types that define
264f904a612d9444ab36c07a8e619c113432e046f49vladlosev// copy constructor, operator=(), operator+(), and operator<().
265f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass DogAdder {
266f904a612d9444ab36c07a8e619c113432e046f49vladlosev public:
2677de3401f5f8c2a61476a3623e9802f973764fc27zhanyong.wan  explicit DogAdder(const char* a_value) : value_(a_value) {}
268f904a612d9444ab36c07a8e619c113432e046f49vladlosev  DogAdder(const DogAdder& other) : value_(other.value_.c_str()) {}
269f904a612d9444ab36c07a8e619c113432e046f49vladlosev
270f904a612d9444ab36c07a8e619c113432e046f49vladlosev  DogAdder operator=(const DogAdder& other) {
271f904a612d9444ab36c07a8e619c113432e046f49vladlosev    if (this != &other)
272f904a612d9444ab36c07a8e619c113432e046f49vladlosev      value_ = other.value_;
273f904a612d9444ab36c07a8e619c113432e046f49vladlosev    return *this;
274f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
275f904a612d9444ab36c07a8e619c113432e046f49vladlosev  DogAdder operator+(const DogAdder& other) const {
276f904a612d9444ab36c07a8e619c113432e046f49vladlosev    Message msg;
277f904a612d9444ab36c07a8e619c113432e046f49vladlosev    msg << value_.c_str() << other.value_.c_str();
278f904a612d9444ab36c07a8e619c113432e046f49vladlosev    return DogAdder(msg.GetString().c_str());
279f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
280f904a612d9444ab36c07a8e619c113432e046f49vladlosev  bool operator<(const DogAdder& other) const {
281f904a612d9444ab36c07a8e619c113432e046f49vladlosev    return value_ < other.value_;
282f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
28303c314931649a999b0cf5deb0a434a1009157416jgm@google.com  const std::string& value() const { return value_; }
284f904a612d9444ab36c07a8e619c113432e046f49vladlosev
285f904a612d9444ab36c07a8e619c113432e046f49vladlosev private:
28603c314931649a999b0cf5deb0a434a1009157416jgm@google.com  std::string value_;
287f904a612d9444ab36c07a8e619c113432e046f49vladlosev};
288f904a612d9444ab36c07a8e619c113432e046f49vladlosev
289f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(RangeTest, WorksWithACustomType) {
290f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<DogAdder> gen =
291f904a612d9444ab36c07a8e619c113432e046f49vladlosev      Range(DogAdder("cat"), DogAdder("catdogdog"), DogAdder("dog"));
292f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ParamGenerator<DogAdder>::iterator it = gen.begin();
293f904a612d9444ab36c07a8e619c113432e046f49vladlosev
294f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ASSERT_FALSE(it == gen.end());
295f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_STREQ("cat", it->value().c_str());
296f904a612d9444ab36c07a8e619c113432e046f49vladlosev
297f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ASSERT_FALSE(++it == gen.end());
298f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_STREQ("catdog", it->value().c_str());
299f904a612d9444ab36c07a8e619c113432e046f49vladlosev
300f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(++it == gen.end());
301f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
302f904a612d9444ab36c07a8e619c113432e046f49vladlosev
303f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass IntWrapper {
304f904a612d9444ab36c07a8e619c113432e046f49vladlosev public:
3057de3401f5f8c2a61476a3623e9802f973764fc27zhanyong.wan  explicit IntWrapper(int a_value) : value_(a_value) {}
306f904a612d9444ab36c07a8e619c113432e046f49vladlosev  IntWrapper(const IntWrapper& other) : value_(other.value_) {}
307f904a612d9444ab36c07a8e619c113432e046f49vladlosev
308f904a612d9444ab36c07a8e619c113432e046f49vladlosev  IntWrapper operator=(const IntWrapper& other) {
309f904a612d9444ab36c07a8e619c113432e046f49vladlosev    value_ = other.value_;
310f904a612d9444ab36c07a8e619c113432e046f49vladlosev    return *this;
311f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
312f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // operator+() adds a different type.
313f904a612d9444ab36c07a8e619c113432e046f49vladlosev  IntWrapper operator+(int other) const { return IntWrapper(value_ + other); }
314f904a612d9444ab36c07a8e619c113432e046f49vladlosev  bool operator<(const IntWrapper& other) const {
315f904a612d9444ab36c07a8e619c113432e046f49vladlosev    return value_ < other.value_;
316f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
317f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int value() const { return value_; }
318f904a612d9444ab36c07a8e619c113432e046f49vladlosev
319f904a612d9444ab36c07a8e619c113432e046f49vladlosev private:
320f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int value_;
321f904a612d9444ab36c07a8e619c113432e046f49vladlosev};
322f904a612d9444ab36c07a8e619c113432e046f49vladlosev
323f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(RangeTest, WorksWithACustomTypeWithDifferentIncrementType) {
324f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<IntWrapper> gen = Range(IntWrapper(0), IntWrapper(2));
325f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ParamGenerator<IntWrapper>::iterator it = gen.begin();
326f904a612d9444ab36c07a8e619c113432e046f49vladlosev
327f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ASSERT_FALSE(it == gen.end());
328f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(0, it->value());
329f904a612d9444ab36c07a8e619c113432e046f49vladlosev
330f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ASSERT_FALSE(++it == gen.end());
331f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(1, it->value());
332f904a612d9444ab36c07a8e619c113432e046f49vladlosev
333f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_TRUE(++it == gen.end());
334f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
335f904a612d9444ab36c07a8e619c113432e046f49vladlosev
336f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that ValuesIn() with an array parameter generates
337f904a612d9444ab36c07a8e619c113432e046f49vladlosev// the expected sequence.
338f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesInTest, ValuesInArray) {
339f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int array[] = {3, 5, 8};
340f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = ValuesIn(array);
341f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, array);
342f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
343f904a612d9444ab36c07a8e619c113432e046f49vladlosev
344f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that ValuesIn() with a const array parameter generates
345f904a612d9444ab36c07a8e619c113432e046f49vladlosev// the expected sequence.
346f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesInTest, ValuesInConstArray) {
347f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int array[] = {3, 5, 8};
348f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = ValuesIn(array);
349f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, array);
350f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
351f904a612d9444ab36c07a8e619c113432e046f49vladlosev
352f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Edge case. Tests that ValuesIn() with an array parameter containing a
353f904a612d9444ab36c07a8e619c113432e046f49vladlosev// single element generates the single element sequence.
354f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesInTest, ValuesInSingleElementArray) {
355f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int array[] = {42};
356f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = ValuesIn(array);
357f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, array);
358f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
359f904a612d9444ab36c07a8e619c113432e046f49vladlosev
360f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that ValuesIn() generates the expected sequence for an STL
361f904a612d9444ab36c07a8e619c113432e046f49vladlosev// container (vector).
362f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesInTest, ValuesInVector) {
363f904a612d9444ab36c07a8e619c113432e046f49vladlosev  typedef ::std::vector<int> ContainerType;
364f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ContainerType values;
365f904a612d9444ab36c07a8e619c113432e046f49vladlosev  values.push_back(3);
366f904a612d9444ab36c07a8e619c113432e046f49vladlosev  values.push_back(5);
367f904a612d9444ab36c07a8e619c113432e046f49vladlosev  values.push_back(8);
368f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = ValuesIn(values);
369f904a612d9444ab36c07a8e619c113432e046f49vladlosev
370f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {3, 5, 8};
371f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
372f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
373f904a612d9444ab36c07a8e619c113432e046f49vladlosev
374f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that ValuesIn() generates the expected sequence.
375f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesInTest, ValuesInIteratorRange) {
376f904a612d9444ab36c07a8e619c113432e046f49vladlosev  typedef ::std::vector<int> ContainerType;
377f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ContainerType values;
378f904a612d9444ab36c07a8e619c113432e046f49vladlosev  values.push_back(3);
379f904a612d9444ab36c07a8e619c113432e046f49vladlosev  values.push_back(5);
380f904a612d9444ab36c07a8e619c113432e046f49vladlosev  values.push_back(8);
381f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
382f904a612d9444ab36c07a8e619c113432e046f49vladlosev
383f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {3, 5, 8};
384f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
385f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
386f904a612d9444ab36c07a8e619c113432e046f49vladlosev
387f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Edge case. Tests that ValuesIn() provided with an iterator range specifying a
388f904a612d9444ab36c07a8e619c113432e046f49vladlosev// single value generates a single-element sequence.
389f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesInTest, ValuesInSingleElementIteratorRange) {
390f904a612d9444ab36c07a8e619c113432e046f49vladlosev  typedef ::std::vector<int> ContainerType;
391f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ContainerType values;
392f904a612d9444ab36c07a8e619c113432e046f49vladlosev  values.push_back(42);
393f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
394f904a612d9444ab36c07a8e619c113432e046f49vladlosev
395f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {42};
396f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
397f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
398f904a612d9444ab36c07a8e619c113432e046f49vladlosev
399f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Edge case. Tests that ValuesIn() provided with an empty iterator range
400f904a612d9444ab36c07a8e619c113432e046f49vladlosev// generates an empty sequence.
401f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesInTest, ValuesInEmptyIteratorRange) {
402f904a612d9444ab36c07a8e619c113432e046f49vladlosev  typedef ::std::vector<int> ContainerType;
403f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ContainerType values;
404f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
405f904a612d9444ab36c07a8e619c113432e046f49vladlosev
406f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGeneratorIsEmpty(gen);
407f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
408f904a612d9444ab36c07a8e619c113432e046f49vladlosev
409f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that the Values() generates the expected sequence.
410f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesTest, ValuesWorks) {
411f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Values(3, 5, 8);
412f904a612d9444ab36c07a8e619c113432e046f49vladlosev
413f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {3, 5, 8};
414f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
415f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
416f904a612d9444ab36c07a8e619c113432e046f49vladlosev
417f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that Values() generates the expected sequences from elements of
418f904a612d9444ab36c07a8e619c113432e046f49vladlosev// different types convertible to ParamGenerator's parameter type.
419f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesTest, ValuesWorksForValuesOfCompatibleTypes) {
420f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<double> gen = Values(3, 5.0f, 8.0);
421f904a612d9444ab36c07a8e619c113432e046f49vladlosev
422f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const double expected_values[] = {3.0, 5.0, 8.0};
423f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
424f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
425f904a612d9444ab36c07a8e619c113432e046f49vladlosev
426f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesTest, ValuesWorksForMaxLengthList) {
427f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Values(
428f904a612d9444ab36c07a8e619c113432e046f49vladlosev      10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
429f904a612d9444ab36c07a8e619c113432e046f49vladlosev      110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
430f904a612d9444ab36c07a8e619c113432e046f49vladlosev      210, 220, 230, 240, 250, 260, 270, 280, 290, 300,
431f904a612d9444ab36c07a8e619c113432e046f49vladlosev      310, 320, 330, 340, 350, 360, 370, 380, 390, 400,
432f904a612d9444ab36c07a8e619c113432e046f49vladlosev      410, 420, 430, 440, 450, 460, 470, 480, 490, 500);
433f904a612d9444ab36c07a8e619c113432e046f49vladlosev
434f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {
435f904a612d9444ab36c07a8e619c113432e046f49vladlosev      10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
436f904a612d9444ab36c07a8e619c113432e046f49vladlosev      110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
437f904a612d9444ab36c07a8e619c113432e046f49vladlosev      210, 220, 230, 240, 250, 260, 270, 280, 290, 300,
438f904a612d9444ab36c07a8e619c113432e046f49vladlosev      310, 320, 330, 340, 350, 360, 370, 380, 390, 400,
439f904a612d9444ab36c07a8e619c113432e046f49vladlosev      410, 420, 430, 440, 450, 460, 470, 480, 490, 500};
440f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
441f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
442f904a612d9444ab36c07a8e619c113432e046f49vladlosev
443f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Edge case test. Tests that single-parameter Values() generates the sequence
444f904a612d9444ab36c07a8e619c113432e046f49vladlosev// with the single value.
445f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ValuesTest, ValuesWithSingleParameter) {
446f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen = Values(42);
447f904a612d9444ab36c07a8e619c113432e046f49vladlosev
448f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {42};
449f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
450f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
451f904a612d9444ab36c07a8e619c113432e046f49vladlosev
452f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that Bool() generates sequence (false, true).
453f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(BoolTest, BoolWorks) {
454f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<bool> gen = Bool();
455f904a612d9444ab36c07a8e619c113432e046f49vladlosev
456f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const bool expected_values[] = {false, true};
457f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
458f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
459f904a612d9444ab36c07a8e619c113432e046f49vladlosev
460733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# if GTEST_HAS_COMBINE
461f904a612d9444ab36c07a8e619c113432e046f49vladlosev
462f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that Combine() with two parameters generates the expected sequence.
463f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(CombineTest, CombineWithTwoParameters) {
464f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const char* foo = "foo";
465f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const char* bar = "bar";
466f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<tuple<const char*, int> > gen =
467f904a612d9444ab36c07a8e619c113432e046f49vladlosev      Combine(Values(foo, bar), Values(3, 4));
468f904a612d9444ab36c07a8e619c113432e046f49vladlosev
469f904a612d9444ab36c07a8e619c113432e046f49vladlosev  tuple<const char*, int> expected_values[] = {
470f904a612d9444ab36c07a8e619c113432e046f49vladlosev    make_tuple(foo, 3), make_tuple(foo, 4),
471f904a612d9444ab36c07a8e619c113432e046f49vladlosev    make_tuple(bar, 3), make_tuple(bar, 4)};
472f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
473f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
474f904a612d9444ab36c07a8e619c113432e046f49vladlosev
475f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that Combine() with three parameters generates the expected sequence.
476f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(CombineTest, CombineWithThreeParameters) {
477f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<tuple<int, int, int> > gen = Combine(Values(0, 1),
478f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                            Values(3, 4),
479f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                            Values(5, 6));
480f904a612d9444ab36c07a8e619c113432e046f49vladlosev  tuple<int, int, int> expected_values[] = {
481f904a612d9444ab36c07a8e619c113432e046f49vladlosev    make_tuple(0, 3, 5), make_tuple(0, 3, 6),
482f904a612d9444ab36c07a8e619c113432e046f49vladlosev    make_tuple(0, 4, 5), make_tuple(0, 4, 6),
483f904a612d9444ab36c07a8e619c113432e046f49vladlosev    make_tuple(1, 3, 5), make_tuple(1, 3, 6),
484f904a612d9444ab36c07a8e619c113432e046f49vladlosev    make_tuple(1, 4, 5), make_tuple(1, 4, 6)};
485f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
486f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
487f904a612d9444ab36c07a8e619c113432e046f49vladlosev
488f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that the Combine() with the first parameter generating a single value
489f904a612d9444ab36c07a8e619c113432e046f49vladlosev// sequence generates a sequence with the number of elements equal to the
490f904a612d9444ab36c07a8e619c113432e046f49vladlosev// number of elements in the sequence generated by the second parameter.
491f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(CombineTest, CombineWithFirstParameterSingleValue) {
492f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<tuple<int, int> > gen = Combine(Values(42),
493f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Values(0, 1));
494f904a612d9444ab36c07a8e619c113432e046f49vladlosev
495f904a612d9444ab36c07a8e619c113432e046f49vladlosev  tuple<int, int> expected_values[] = {make_tuple(42, 0), make_tuple(42, 1)};
496f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
497f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
498f904a612d9444ab36c07a8e619c113432e046f49vladlosev
499f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that the Combine() with the second parameter generating a single value
500f904a612d9444ab36c07a8e619c113432e046f49vladlosev// sequence generates a sequence with the number of elements equal to the
501f904a612d9444ab36c07a8e619c113432e046f49vladlosev// number of elements in the sequence generated by the first parameter.
502f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(CombineTest, CombineWithSecondParameterSingleValue) {
503f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),
504f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Values(42));
505f904a612d9444ab36c07a8e619c113432e046f49vladlosev
506f904a612d9444ab36c07a8e619c113432e046f49vladlosev  tuple<int, int> expected_values[] = {make_tuple(0, 42), make_tuple(1, 42)};
507f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
508f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
509f904a612d9444ab36c07a8e619c113432e046f49vladlosev
510f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that when the first parameter produces an empty sequence,
511f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine() produces an empty sequence, too.
512f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(CombineTest, CombineWithFirstParameterEmptyRange) {
513f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<tuple<int, int> > gen = Combine(Range(0, 0),
514f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Values(0, 1));
515f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGeneratorIsEmpty(gen);
516f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
517f904a612d9444ab36c07a8e619c113432e046f49vladlosev
518f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that when the second parameter produces an empty sequence,
519f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine() produces an empty sequence, too.
520f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(CombineTest, CombineWithSecondParameterEmptyRange) {
521f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),
522f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Range(1, 1));
523f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGeneratorIsEmpty(gen);
524f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
525f904a612d9444ab36c07a8e619c113432e046f49vladlosev
526f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Edge case. Tests that combine works with the maximum number
527f904a612d9444ab36c07a8e619c113432e046f49vladlosev// of parameters supported by Google Test (currently 10).
528f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(CombineTest, CombineWithMaxNumberOfParameters) {
529f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const char* foo = "foo";
530f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const char* bar = "bar";
531f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<tuple<const char*, int, int, int, int, int, int, int,
532f904a612d9444ab36c07a8e619c113432e046f49vladlosev                             int, int> > gen = Combine(Values(foo, bar),
533f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Values(1), Values(2),
534f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Values(3), Values(4),
535f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Values(5), Values(6),
536f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Values(7), Values(8),
537f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                                       Values(9));
538f904a612d9444ab36c07a8e619c113432e046f49vladlosev
539f904a612d9444ab36c07a8e619c113432e046f49vladlosev  tuple<const char*, int, int, int, int, int, int, int, int, int>
540f904a612d9444ab36c07a8e619c113432e046f49vladlosev      expected_values[] = {make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),
541f904a612d9444ab36c07a8e619c113432e046f49vladlosev                           make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};
542f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
543f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
544f904a612d9444ab36c07a8e619c113432e046f49vladlosev
545733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# endif  // GTEST_HAS_COMBINE
546f904a612d9444ab36c07a8e619c113432e046f49vladlosev
547f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that an generator produces correct sequence after being
548f904a612d9444ab36c07a8e619c113432e046f49vladlosev// assigned from another generator.
549f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(ParamGeneratorTest, AssignmentWorks) {
550f904a612d9444ab36c07a8e619c113432e046f49vladlosev  ParamGenerator<int> gen = Values(1, 2);
551f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ParamGenerator<int> gen2 = Values(3, 4);
552f904a612d9444ab36c07a8e619c113432e046f49vladlosev  gen = gen2;
553f904a612d9444ab36c07a8e619c113432e046f49vladlosev
554f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const int expected_values[] = {3, 4};
555f904a612d9444ab36c07a8e619c113432e046f49vladlosev  VerifyGenerator(gen, expected_values);
556f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
557f904a612d9444ab36c07a8e619c113432e046f49vladlosev
558f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This test verifies that the tests are expanded and run as specified:
559f904a612d9444ab36c07a8e619c113432e046f49vladlosev// one test per element from the sequence produced by the generator
560f904a612d9444ab36c07a8e619c113432e046f49vladlosev// specified in INSTANTIATE_TEST_CASE_P. It also verifies that the test's
561f904a612d9444ab36c07a8e619c113432e046f49vladlosev// fixture constructor, SetUp(), and TearDown() have run and have been
562f904a612d9444ab36c07a8e619c113432e046f49vladlosev// supplied with the correct parameters.
563f904a612d9444ab36c07a8e619c113432e046f49vladlosev
564f904a612d9444ab36c07a8e619c113432e046f49vladlosev// The use of environment object allows detection of the case where no test
565f904a612d9444ab36c07a8e619c113432e046f49vladlosev// case functionality is run at all. In this case TestCaseTearDown will not
566f904a612d9444ab36c07a8e619c113432e046f49vladlosev// be able to detect missing tests, naturally.
567f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <int kExpectedCalls>
568f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass TestGenerationEnvironment : public ::testing::Environment {
569f904a612d9444ab36c07a8e619c113432e046f49vladlosev public:
570f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static TestGenerationEnvironment* Instance() {
571f904a612d9444ab36c07a8e619c113432e046f49vladlosev    static TestGenerationEnvironment* instance = new TestGenerationEnvironment;
572f904a612d9444ab36c07a8e619c113432e046f49vladlosev    return instance;
573f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
574f904a612d9444ab36c07a8e619c113432e046f49vladlosev
575f904a612d9444ab36c07a8e619c113432e046f49vladlosev  void FixtureConstructorExecuted() { fixture_constructor_count_++; }
576f904a612d9444ab36c07a8e619c113432e046f49vladlosev  void SetUpExecuted() { set_up_count_++; }
577f904a612d9444ab36c07a8e619c113432e046f49vladlosev  void TearDownExecuted() { tear_down_count_++; }
578f904a612d9444ab36c07a8e619c113432e046f49vladlosev  void TestBodyExecuted() { test_body_count_++; }
579f904a612d9444ab36c07a8e619c113432e046f49vladlosev
580f904a612d9444ab36c07a8e619c113432e046f49vladlosev  virtual void TearDown() {
581f904a612d9444ab36c07a8e619c113432e046f49vladlosev    // If all MultipleTestGenerationTest tests have been de-selected
582f904a612d9444ab36c07a8e619c113432e046f49vladlosev    // by the filter flag, the following checks make no sense.
583f904a612d9444ab36c07a8e619c113432e046f49vladlosev    bool perform_check = false;
584f904a612d9444ab36c07a8e619c113432e046f49vladlosev
585f904a612d9444ab36c07a8e619c113432e046f49vladlosev    for (int i = 0; i < kExpectedCalls; ++i) {
586f904a612d9444ab36c07a8e619c113432e046f49vladlosev      Message msg;
587f904a612d9444ab36c07a8e619c113432e046f49vladlosev      msg << "TestsExpandedAndRun/" << i;
588f904a612d9444ab36c07a8e619c113432e046f49vladlosev      if (UnitTestOptions::FilterMatchesTest(
589f904a612d9444ab36c07a8e619c113432e046f49vladlosev             "TestExpansionModule/MultipleTestGenerationTest",
590f904a612d9444ab36c07a8e619c113432e046f49vladlosev              msg.GetString().c_str())) {
591f904a612d9444ab36c07a8e619c113432e046f49vladlosev        perform_check = true;
592f904a612d9444ab36c07a8e619c113432e046f49vladlosev      }
593f904a612d9444ab36c07a8e619c113432e046f49vladlosev    }
594f904a612d9444ab36c07a8e619c113432e046f49vladlosev    if (perform_check) {
595f904a612d9444ab36c07a8e619c113432e046f49vladlosev      EXPECT_EQ(kExpectedCalls, fixture_constructor_count_)
596f904a612d9444ab36c07a8e619c113432e046f49vladlosev          << "Fixture constructor of ParamTestGenerationTest test case "
597f904a612d9444ab36c07a8e619c113432e046f49vladlosev          << "has not been run as expected.";
598f904a612d9444ab36c07a8e619c113432e046f49vladlosev      EXPECT_EQ(kExpectedCalls, set_up_count_)
599f904a612d9444ab36c07a8e619c113432e046f49vladlosev          << "Fixture SetUp method of ParamTestGenerationTest test case "
600f904a612d9444ab36c07a8e619c113432e046f49vladlosev          << "has not been run as expected.";
601f904a612d9444ab36c07a8e619c113432e046f49vladlosev      EXPECT_EQ(kExpectedCalls, tear_down_count_)
602f904a612d9444ab36c07a8e619c113432e046f49vladlosev          << "Fixture TearDown method of ParamTestGenerationTest test case "
603f904a612d9444ab36c07a8e619c113432e046f49vladlosev          << "has not been run as expected.";
604f904a612d9444ab36c07a8e619c113432e046f49vladlosev      EXPECT_EQ(kExpectedCalls, test_body_count_)
605f904a612d9444ab36c07a8e619c113432e046f49vladlosev          << "Test in ParamTestGenerationTest test case "
606f904a612d9444ab36c07a8e619c113432e046f49vladlosev          << "has not been run as expected.";
607f904a612d9444ab36c07a8e619c113432e046f49vladlosev    }
608f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
60993fed47dbf8e6bc3d39d3f769cb5039551747257vladlosev
610f904a612d9444ab36c07a8e619c113432e046f49vladlosev private:
611f904a612d9444ab36c07a8e619c113432e046f49vladlosev  TestGenerationEnvironment() : fixture_constructor_count_(0), set_up_count_(0),
612f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                tear_down_count_(0), test_body_count_(0) {}
613f904a612d9444ab36c07a8e619c113432e046f49vladlosev
614f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int fixture_constructor_count_;
615f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int set_up_count_;
616f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int tear_down_count_;
617f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int test_body_count_;
618f904a612d9444ab36c07a8e619c113432e046f49vladlosev
619f904a612d9444ab36c07a8e619c113432e046f49vladlosev  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationEnvironment);
620f904a612d9444ab36c07a8e619c113432e046f49vladlosev};
621f904a612d9444ab36c07a8e619c113432e046f49vladlosev
622f904a612d9444ab36c07a8e619c113432e046f49vladlosevconst int test_generation_params[] = {36, 42, 72};
623f904a612d9444ab36c07a8e619c113432e046f49vladlosev
624f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass TestGenerationTest : public TestWithParam<int> {
625f904a612d9444ab36c07a8e619c113432e046f49vladlosev public:
626f904a612d9444ab36c07a8e619c113432e046f49vladlosev  enum {
627f904a612d9444ab36c07a8e619c113432e046f49vladlosev    PARAMETER_COUNT =
628f904a612d9444ab36c07a8e619c113432e046f49vladlosev        sizeof(test_generation_params)/sizeof(test_generation_params[0])
629f904a612d9444ab36c07a8e619c113432e046f49vladlosev  };
630f904a612d9444ab36c07a8e619c113432e046f49vladlosev
631f904a612d9444ab36c07a8e619c113432e046f49vladlosev  typedef TestGenerationEnvironment<PARAMETER_COUNT> Environment;
632f904a612d9444ab36c07a8e619c113432e046f49vladlosev
633f904a612d9444ab36c07a8e619c113432e046f49vladlosev  TestGenerationTest() {
634f904a612d9444ab36c07a8e619c113432e046f49vladlosev    Environment::Instance()->FixtureConstructorExecuted();
635f904a612d9444ab36c07a8e619c113432e046f49vladlosev    current_parameter_ = GetParam();
636f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
637f904a612d9444ab36c07a8e619c113432e046f49vladlosev  virtual void SetUp() {
638f904a612d9444ab36c07a8e619c113432e046f49vladlosev    Environment::Instance()->SetUpExecuted();
639f904a612d9444ab36c07a8e619c113432e046f49vladlosev    EXPECT_EQ(current_parameter_, GetParam());
640f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
641f904a612d9444ab36c07a8e619c113432e046f49vladlosev  virtual void TearDown() {
642f904a612d9444ab36c07a8e619c113432e046f49vladlosev    Environment::Instance()->TearDownExecuted();
643f904a612d9444ab36c07a8e619c113432e046f49vladlosev    EXPECT_EQ(current_parameter_, GetParam());
644f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
645f904a612d9444ab36c07a8e619c113432e046f49vladlosev
646f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static void SetUpTestCase() {
647f904a612d9444ab36c07a8e619c113432e046f49vladlosev    bool all_tests_in_test_case_selected = true;
648f904a612d9444ab36c07a8e619c113432e046f49vladlosev
649f904a612d9444ab36c07a8e619c113432e046f49vladlosev    for (int i = 0; i < PARAMETER_COUNT; ++i) {
650f904a612d9444ab36c07a8e619c113432e046f49vladlosev      Message test_name;
651f904a612d9444ab36c07a8e619c113432e046f49vladlosev      test_name << "TestsExpandedAndRun/" << i;
652f904a612d9444ab36c07a8e619c113432e046f49vladlosev      if ( !UnitTestOptions::FilterMatchesTest(
653f904a612d9444ab36c07a8e619c113432e046f49vladlosev                "TestExpansionModule/MultipleTestGenerationTest",
654f904a612d9444ab36c07a8e619c113432e046f49vladlosev                test_name.GetString())) {
655f904a612d9444ab36c07a8e619c113432e046f49vladlosev        all_tests_in_test_case_selected = false;
656f904a612d9444ab36c07a8e619c113432e046f49vladlosev      }
657f904a612d9444ab36c07a8e619c113432e046f49vladlosev    }
658f904a612d9444ab36c07a8e619c113432e046f49vladlosev    EXPECT_TRUE(all_tests_in_test_case_selected)
659f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "When running the TestGenerationTest test case all of its tests\n"
660f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "must be selected by the filter flag for the test case to pass.\n"
661f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "If not all of them are enabled, we can't reliably conclude\n"
662f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "that the correct number of tests have been generated.";
663f904a612d9444ab36c07a8e619c113432e046f49vladlosev
664f904a612d9444ab36c07a8e619c113432e046f49vladlosev    collected_parameters_.clear();
665f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
666f904a612d9444ab36c07a8e619c113432e046f49vladlosev
667f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static void TearDownTestCase() {
668f904a612d9444ab36c07a8e619c113432e046f49vladlosev    vector<int> expected_values(test_generation_params,
669f904a612d9444ab36c07a8e619c113432e046f49vladlosev                                test_generation_params + PARAMETER_COUNT);
670f904a612d9444ab36c07a8e619c113432e046f49vladlosev    // Test execution order is not guaranteed by Google Test,
671f904a612d9444ab36c07a8e619c113432e046f49vladlosev    // so the order of values in collected_parameters_ can be
672f904a612d9444ab36c07a8e619c113432e046f49vladlosev    // different and we have to sort to compare.
673f904a612d9444ab36c07a8e619c113432e046f49vladlosev    sort(expected_values.begin(), expected_values.end());
674f904a612d9444ab36c07a8e619c113432e046f49vladlosev    sort(collected_parameters_.begin(), collected_parameters_.end());
675f904a612d9444ab36c07a8e619c113432e046f49vladlosev
676f904a612d9444ab36c07a8e619c113432e046f49vladlosev    EXPECT_TRUE(collected_parameters_ == expected_values);
677f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
67893fed47dbf8e6bc3d39d3f769cb5039551747257vladlosev
679f904a612d9444ab36c07a8e619c113432e046f49vladlosev protected:
680f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int current_parameter_;
681f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static vector<int> collected_parameters_;
682f904a612d9444ab36c07a8e619c113432e046f49vladlosev
683f904a612d9444ab36c07a8e619c113432e046f49vladlosev private:
684f904a612d9444ab36c07a8e619c113432e046f49vladlosev  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationTest);
685f904a612d9444ab36c07a8e619c113432e046f49vladlosev};
686f904a612d9444ab36c07a8e619c113432e046f49vladlosevvector<int> TestGenerationTest::collected_parameters_;
687f904a612d9444ab36c07a8e619c113432e046f49vladlosev
688f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(TestGenerationTest, TestsExpandedAndRun) {
689f904a612d9444ab36c07a8e619c113432e046f49vladlosev  Environment::Instance()->TestBodyExecuted();
690f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(current_parameter_, GetParam());
691f904a612d9444ab36c07a8e619c113432e046f49vladlosev  collected_parameters_.push_back(GetParam());
692f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
693f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(TestExpansionModule, TestGenerationTest,
694f904a612d9444ab36c07a8e619c113432e046f49vladlosev                        ValuesIn(test_generation_params));
695f904a612d9444ab36c07a8e619c113432e046f49vladlosev
696f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This test verifies that the element sequence (third parameter of
697d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// INSTANTIATE_TEST_CASE_P) is evaluated in InitGoogleTest() and neither at
698d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// the call site of INSTANTIATE_TEST_CASE_P nor in RUN_ALL_TESTS().  For
699d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// that, we declare param_value_ to be a static member of
700d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// GeneratorEvaluationTest and initialize it to 0.  We set it to 1 in
701d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// main(), just before invocation of InitGoogleTest().  After calling
702d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// InitGoogleTest(), we set the value to 2.  If the sequence is evaluated
703d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// before or after InitGoogleTest, INSTANTIATE_TEST_CASE_P will create a
704d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// test with parameter other than 1, and the test body will fail the
705d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev// assertion.
706f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass GeneratorEvaluationTest : public TestWithParam<int> {
707f904a612d9444ab36c07a8e619c113432e046f49vladlosev public:
708f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static int param_value() { return param_value_; }
709f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static void set_param_value(int param_value) { param_value_ = param_value; }
710f904a612d9444ab36c07a8e619c113432e046f49vladlosev
711f904a612d9444ab36c07a8e619c113432e046f49vladlosev private:
712f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static int param_value_;
713f904a612d9444ab36c07a8e619c113432e046f49vladlosev};
714f904a612d9444ab36c07a8e619c113432e046f49vladlosevint GeneratorEvaluationTest::param_value_ = 0;
715f904a612d9444ab36c07a8e619c113432e046f49vladlosev
716f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(GeneratorEvaluationTest, GeneratorsEvaluatedInMain) {
717f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(1, GetParam());
718f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
719f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(GenEvalModule,
720f904a612d9444ab36c07a8e619c113432e046f49vladlosev                        GeneratorEvaluationTest,
721f904a612d9444ab36c07a8e619c113432e046f49vladlosev                        Values(GeneratorEvaluationTest::param_value()));
722f904a612d9444ab36c07a8e619c113432e046f49vladlosev
723f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that generators defined in a different translation unit are
724f904a612d9444ab36c07a8e619c113432e046f49vladlosev// functional. Generator extern_gen is defined in gtest-param-test_test2.cc.
725f904a612d9444ab36c07a8e619c113432e046f49vladlosevextern ParamGenerator<int> extern_gen;
726f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass ExternalGeneratorTest : public TestWithParam<int> {};
727f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(ExternalGeneratorTest, ExternalGenerator) {
728f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // Sequence produced by extern_gen contains only a single value
729f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // which we verify here.
730f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(GetParam(), 33);
731f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
732f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(ExternalGeneratorModule,
733f904a612d9444ab36c07a8e619c113432e046f49vladlosev                        ExternalGeneratorTest,
734f904a612d9444ab36c07a8e619c113432e046f49vladlosev                        extern_gen);
735f904a612d9444ab36c07a8e619c113432e046f49vladlosev
736f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that a parameterized test case can be defined in one translation
737f904a612d9444ab36c07a8e619c113432e046f49vladlosev// unit and instantiated in another. This test will be instantiated in
738f904a612d9444ab36c07a8e619c113432e046f49vladlosev// gtest-param-test_test2.cc. ExternalInstantiationTest fixture class is
739f904a612d9444ab36c07a8e619c113432e046f49vladlosev// defined in gtest-param-test_test.h.
740f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(ExternalInstantiationTest, IsMultipleOf33) {
741f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(0, GetParam() % 33);
742f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
743f904a612d9444ab36c07a8e619c113432e046f49vladlosev
744f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that a parameterized test case can be instantiated with multiple
745f904a612d9444ab36c07a8e619c113432e046f49vladlosev// generators.
746f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass MultipleInstantiationTest : public TestWithParam<int> {};
747f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(MultipleInstantiationTest, AllowsMultipleInstances) {
748f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
749f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));
750f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));
751f904a612d9444ab36c07a8e619c113432e046f49vladlosev
752f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that a parameterized test case can be instantiated
753f904a612d9444ab36c07a8e619c113432e046f49vladlosev// in multiple translation units. This test will be instantiated
754f904a612d9444ab36c07a8e619c113432e046f49vladlosev// here and in gtest-param-test_test2.cc.
755f904a612d9444ab36c07a8e619c113432e046f49vladlosev// InstantiationInMultipleTranslationUnitsTest fixture class
756f904a612d9444ab36c07a8e619c113432e046f49vladlosev// is defined in gtest-param-test_test.h.
757f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(InstantiationInMultipleTranslaionUnitsTest, IsMultipleOf42) {
758f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(0, GetParam() % 42);
759f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
760f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(Sequence1,
761f904a612d9444ab36c07a8e619c113432e046f49vladlosev                        InstantiationInMultipleTranslaionUnitsTest,
762f904a612d9444ab36c07a8e619c113432e046f49vladlosev                        Values(42, 42*2));
763f904a612d9444ab36c07a8e619c113432e046f49vladlosev
764f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that each iteration of parameterized test runs in a separate test
765f904a612d9444ab36c07a8e619c113432e046f49vladlosev// object.
766f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass SeparateInstanceTest : public TestWithParam<int> {
767f904a612d9444ab36c07a8e619c113432e046f49vladlosev public:
768f904a612d9444ab36c07a8e619c113432e046f49vladlosev  SeparateInstanceTest() : count_(0) {}
769f904a612d9444ab36c07a8e619c113432e046f49vladlosev
770f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static void TearDownTestCase() {
771f904a612d9444ab36c07a8e619c113432e046f49vladlosev    EXPECT_GE(global_count_, 2)
772f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "If some (but not all) SeparateInstanceTest tests have been "
773f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "filtered out this test will fail. Make sure that all "
774f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "GeneratorEvaluationTest are selected or de-selected together "
775f904a612d9444ab36c07a8e619c113432e046f49vladlosev        << "by the test filter.";
776f904a612d9444ab36c07a8e619c113432e046f49vladlosev  }
777f904a612d9444ab36c07a8e619c113432e046f49vladlosev
778f904a612d9444ab36c07a8e619c113432e046f49vladlosev protected:
779f904a612d9444ab36c07a8e619c113432e046f49vladlosev  int count_;
780f904a612d9444ab36c07a8e619c113432e046f49vladlosev  static int global_count_;
781f904a612d9444ab36c07a8e619c113432e046f49vladlosev};
782f904a612d9444ab36c07a8e619c113432e046f49vladlosevint SeparateInstanceTest::global_count_ = 0;
783f904a612d9444ab36c07a8e619c113432e046f49vladlosev
784f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(SeparateInstanceTest, TestsRunInSeparateInstances) {
785f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_EQ(0, count_++);
786f904a612d9444ab36c07a8e619c113432e046f49vladlosev  global_count_++;
787f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
788f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));
789f904a612d9444ab36c07a8e619c113432e046f49vladlosev
790f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Tests that all instantiations of a test have named appropriately. Test
791f904a612d9444ab36c07a8e619c113432e046f49vladlosev// defined with TEST_P(TestCaseName, TestName) and instantiated with
792f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(SequenceName, TestCaseName, generator) must be named
793f904a612d9444ab36c07a8e619c113432e046f49vladlosev// SequenceName/TestCaseName.TestName/i, where i is the 0-based index of the
794f904a612d9444ab36c07a8e619c113432e046f49vladlosev// sequence element used to instantiate the test.
795f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass NamingTest : public TestWithParam<int> {};
796f904a612d9444ab36c07a8e619c113432e046f49vladlosev
797a33163a3ddbb60a6c45340e436310f78044c1a7dzhanyong.wanTEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
798f904a612d9444ab36c07a8e619c113432e046f49vladlosev  const ::testing::TestInfo* const test_info =
799f904a612d9444ab36c07a8e619c113432e046f49vladlosev     ::testing::UnitTest::GetInstance()->current_test_info();
800f904a612d9444ab36c07a8e619c113432e046f49vladlosev
801f904a612d9444ab36c07a8e619c113432e046f49vladlosev  EXPECT_STREQ("ZeroToFiveSequence/NamingTest", test_info->test_case_name());
802f904a612d9444ab36c07a8e619c113432e046f49vladlosev
8033a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev  Message index_stream;
804a33163a3ddbb60a6c45340e436310f78044c1a7dzhanyong.wan  index_stream << "TestsReportCorrectNamesAndParameters/" << GetParam();
8053a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev  EXPECT_STREQ(index_stream.GetString().c_str(), test_info->name());
8063a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev
807a33163a3ddbb60a6c45340e436310f78044c1a7dzhanyong.wan  EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
808f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
809f904a612d9444ab36c07a8e619c113432e046f49vladlosev
810f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
811f904a612d9444ab36c07a8e619c113432e046f49vladlosev
8123a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev// Class that cannot be streamed into an ostream.  It needs to be copyable
8133a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev// (and, in case of MSVC, also assignable) in order to be a test parameter
8143a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev// type.  Its default copy constructor and assignment operator do exactly
8153a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev// what we need.
8163a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosevclass Unstreamable {
8173a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev public:
8183a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev  explicit Unstreamable(int value) : value_(value) {}
8193a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev
8203a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev private:
8213a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev  int value_;
8223a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev};
8233a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev
8243a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosevclass CommentTest : public TestWithParam<Unstreamable> {};
8253a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev
826a33163a3ddbb60a6c45340e436310f78044c1a7dzhanyong.wanTEST_P(CommentTest, TestsCorrectlyReportUnstreamableParams) {
8273a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev  const ::testing::TestInfo* const test_info =
8283a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev     ::testing::UnitTest::GetInstance()->current_test_info();
8293a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev
830a33163a3ddbb60a6c45340e436310f78044c1a7dzhanyong.wan  EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
8313a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev}
8323a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev
8333a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosevINSTANTIATE_TEST_CASE_P(InstantiationWithComments,
8343a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev                        CommentTest,
8353a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev                        Values(Unstreamable(1)));
8363a6fc976eaf7f79a3e8212595ccf49d72d37335bvladlosev
83771874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// Verify that we can create a hierarchy of test fixtures, where the base
83871874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// class fixture is not parameterized and the derived class is. In this case
83971874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// ParameterizedDerivedTest inherits from NonParameterizedBaseTest.  We
84071874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// perform simple tests on both.
84171874246c3a054977d94fd4729576484c2af62e9zhanyong.wanclass NonParameterizedBaseTest : public ::testing::Test {
84271874246c3a054977d94fd4729576484c2af62e9zhanyong.wan public:
84371874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  NonParameterizedBaseTest() : n_(17) { }
84471874246c3a054977d94fd4729576484c2af62e9zhanyong.wan protected:
84571874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  int n_;
84671874246c3a054977d94fd4729576484c2af62e9zhanyong.wan};
84771874246c3a054977d94fd4729576484c2af62e9zhanyong.wan
84871874246c3a054977d94fd4729576484c2af62e9zhanyong.wanclass ParameterizedDerivedTest : public NonParameterizedBaseTest,
84971874246c3a054977d94fd4729576484c2af62e9zhanyong.wan                                 public ::testing::WithParamInterface<int> {
85071874246c3a054977d94fd4729576484c2af62e9zhanyong.wan protected:
85171874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  ParameterizedDerivedTest() : count_(0) { }
85271874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  int count_;
85371874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  static int global_count_;
85471874246c3a054977d94fd4729576484c2af62e9zhanyong.wan};
85571874246c3a054977d94fd4729576484c2af62e9zhanyong.wan
85671874246c3a054977d94fd4729576484c2af62e9zhanyong.wanint ParameterizedDerivedTest::global_count_ = 0;
85771874246c3a054977d94fd4729576484c2af62e9zhanyong.wan
85871874246c3a054977d94fd4729576484c2af62e9zhanyong.wanTEST_F(NonParameterizedBaseTest, FixtureIsInitialized) {
85971874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  EXPECT_EQ(17, n_);
86071874246c3a054977d94fd4729576484c2af62e9zhanyong.wan}
86171874246c3a054977d94fd4729576484c2af62e9zhanyong.wan
86271874246c3a054977d94fd4729576484c2af62e9zhanyong.wanTEST_P(ParameterizedDerivedTest, SeesSequence) {
86371874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  EXPECT_EQ(17, n_);
86471874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  EXPECT_EQ(0, count_++);
86571874246c3a054977d94fd4729576484c2af62e9zhanyong.wan  EXPECT_EQ(GetParam(), global_count_++);
86671874246c3a054977d94fd4729576484c2af62e9zhanyong.wan}
86771874246c3a054977d94fd4729576484c2af62e9zhanyong.wan
868726afc27a7873cb99e562df47d57188a09464fa5zhanyong.wanclass ParameterizedDeathTest : public ::testing::TestWithParam<int> { };
869726afc27a7873cb99e562df47d57188a09464fa5zhanyong.wan
870726afc27a7873cb99e562df47d57188a09464fa5zhanyong.wanTEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
871726afc27a7873cb99e562df47d57188a09464fa5zhanyong.wan  EXPECT_DEATH_IF_SUPPORTED(GetParam(),
872726afc27a7873cb99e562df47d57188a09464fa5zhanyong.wan                            ".* value-parameterized test .*");
873726afc27a7873cb99e562df47d57188a09464fa5zhanyong.wan}
874726afc27a7873cb99e562df47d57188a09464fa5zhanyong.wan
87571874246c3a054977d94fd4729576484c2af62e9zhanyong.wanINSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
87671874246c3a054977d94fd4729576484c2af62e9zhanyong.wan
877f904a612d9444ab36c07a8e619c113432e046f49vladlosev#endif  // GTEST_HAS_PARAM_TEST
878f904a612d9444ab36c07a8e619c113432e046f49vladlosev
879f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST(CompileTest, CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined) {
8804cd62602913a032a7aec091d4c8055ff9af95e37zhanyong.wan#if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST
881f904a612d9444ab36c07a8e619c113432e046f49vladlosev  FAIL() << "GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not\n"
882f904a612d9444ab36c07a8e619c113432e046f49vladlosev#endif
883f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
884f904a612d9444ab36c07a8e619c113432e046f49vladlosev
885f904a612d9444ab36c07a8e619c113432e046f49vladlosevint main(int argc, char **argv) {
8864cd62602913a032a7aec091d4c8055ff9af95e37zhanyong.wan#if GTEST_HAS_PARAM_TEST
887f904a612d9444ab36c07a8e619c113432e046f49vladlosev  // Used in TestGenerationTest test case.
888f904a612d9444ab36c07a8e619c113432e046f49vladlosev  AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
889d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev  // Used in GeneratorEvaluationTest test case. Tests that the updated value
890d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev  // will be picked up for instantiating tests in GeneratorEvaluationTest.
891f904a612d9444ab36c07a8e619c113432e046f49vladlosev  GeneratorEvaluationTest::set_param_value(1);
892f904a612d9444ab36c07a8e619c113432e046f49vladlosev#endif  // GTEST_HAS_PARAM_TEST
893f904a612d9444ab36c07a8e619c113432e046f49vladlosev
894cfdfeeb3964b84f6e248b84a259aaee54cde14f3zhanyong.wan  ::testing::InitGoogleTest(&argc, argv);
895d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev
896d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev#if GTEST_HAS_PARAM_TEST
897d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev  // Used in GeneratorEvaluationTest test case. Tests that value updated
898d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev  // here will NOT be used for instantiating tests in
899d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev  // GeneratorEvaluationTest.
900d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev  GeneratorEvaluationTest::set_param_value(2);
901d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev#endif  // GTEST_HAS_PARAM_TEST
902d13d1ed2189fa4284c9d8d202bb88916309682f1vladlosev
903f904a612d9444ab36c07a8e619c113432e046f49vladlosev  return RUN_ALL_TESTS();
904f904a612d9444ab36c07a8e619c113432e046f49vladlosev}
905