Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
googletest-env-var-test_.cc
Go to the documentation of this file.
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 // A helper program for testing that Google Test parses the environment
31 // variables correctly.
32 
33 #include <iostream>
34 
35 #include "gtest/gtest.h"
36 #include "src/gtest-internal-inl.h"
37 
38 using ::std::cout;
39 
40 namespace testing {
41 
42 // The purpose of this is to make the test more realistic by ensuring
43 // that the UnitTest singleton is created before main() is entered.
44 // We don't actual run the TEST itself.
45 TEST(GTestEnvVarTest, Dummy) {}
46 
47 void PrintFlag(const char* flag) {
48  if (strcmp(flag, "break_on_failure") == 0) {
49  cout << GTEST_FLAG_GET(break_on_failure);
50  return;
51  }
52 
53  if (strcmp(flag, "catch_exceptions") == 0) {
54  cout << GTEST_FLAG_GET(catch_exceptions);
55  return;
56  }
57 
58  if (strcmp(flag, "color") == 0) {
59  cout << GTEST_FLAG_GET(color);
60  return;
61  }
62 
63  if (strcmp(flag, "death_test_style") == 0) {
64  cout << GTEST_FLAG_GET(death_test_style);
65  return;
66  }
67 
68  if (strcmp(flag, "death_test_use_fork") == 0) {
69  cout << GTEST_FLAG_GET(death_test_use_fork);
70  return;
71  }
72 
73  if (strcmp(flag, "fail_fast") == 0) {
74  cout << GTEST_FLAG_GET(fail_fast);
75  return;
76  }
77 
78  if (strcmp(flag, "filter") == 0) {
79  cout << GTEST_FLAG_GET(filter);
80  return;
81  }
82 
83  if (strcmp(flag, "output") == 0) {
84  cout << GTEST_FLAG_GET(output);
85  return;
86  }
87 
88  if (strcmp(flag, "brief") == 0) {
89  cout << GTEST_FLAG_GET(brief);
90  return;
91  }
92 
93  if (strcmp(flag, "print_time") == 0) {
94  cout << GTEST_FLAG_GET(print_time);
95  return;
96  }
97 
98  if (strcmp(flag, "repeat") == 0) {
99  cout << GTEST_FLAG_GET(repeat);
100  return;
101  }
102 
103  if (strcmp(flag, "stack_trace_depth") == 0) {
104  cout << GTEST_FLAG_GET(stack_trace_depth);
105  return;
106  }
107 
108  if (strcmp(flag, "throw_on_failure") == 0) {
109  cout << GTEST_FLAG_GET(throw_on_failure);
110  return;
111  }
112 
113  cout << "Invalid flag name " << flag
114  << ". Valid names are break_on_failure, color, filter, etc.\n";
115  exit(1);
116 }
117 
118 } // namespace testing
119 
120 int main(int argc, char** argv) {
121  testing::InitGoogleTest(&argc, argv);
122 
123  if (argc != 2) {
124  cout << "Usage: googletest-env-var-test_ NAME_OF_FLAG\n";
125  return 1;
126  }
127 
128  testing::PrintFlag(argv[1]);
129  return 0;
130 }
int main()
Definition: ad_example.cpp:171
TEST(GTestEnvVarTest, Dummy)
void PrintFlag(const char *flag)
#define GTEST_FLAG_GET(name)
Definition: gtest-port.h:2342
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: gtest.cc:6885