gtest_env_var_test_.cc
Go to the documentation of this file.
00001 // Copyright 2008, Google Inc.
00002 // All rights reserved.
00003 //
00004 // Redistribution and use in source and binary forms, with or without
00005 // modification, are permitted provided that the following conditions are
00006 // met:
00007 //
00008 //     * Redistributions of source code must retain the above copyright
00009 // notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above
00011 // copyright notice, this list of conditions and the following disclaimer
00012 // in the documentation and/or other materials provided with the
00013 // distribution.
00014 //     * Neither the name of Google Inc. nor the names of its
00015 // contributors may be used to endorse or promote products derived from
00016 // this software without specific prior written permission.
00017 //
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // Author: wan@google.com (Zhanyong Wan)
00031 
00032 // A helper program for testing that Google Test parses the environment
00033 // variables correctly.
00034 
00035 #include "gtest/gtest.h"
00036 
00037 #include <iostream>
00038 
00039 #define GTEST_IMPLEMENTATION_ 1
00040 #include "src/gtest-internal-inl.h"
00041 #undef GTEST_IMPLEMENTATION_
00042 
00043 using ::std::cout;
00044 
00045 namespace testing {
00046 
00047 // The purpose of this is to make the test more realistic by ensuring
00048 // that the UnitTest singleton is created before main() is entered.
00049 // We don't actual run the TEST itself.
00050 TEST(GTestEnvVarTest, Dummy) {
00051 }
00052 
00053 void PrintFlag(const char* flag) {
00054   if (strcmp(flag, "break_on_failure") == 0) {
00055     cout << GTEST_FLAG(break_on_failure);
00056     return;
00057   }
00058 
00059   if (strcmp(flag, "catch_exceptions") == 0) {
00060     cout << GTEST_FLAG(catch_exceptions);
00061     return;
00062   }
00063 
00064   if (strcmp(flag, "color") == 0) {
00065     cout << GTEST_FLAG(color);
00066     return;
00067   }
00068 
00069   if (strcmp(flag, "death_test_style") == 0) {
00070     cout << GTEST_FLAG(death_test_style);
00071     return;
00072   }
00073 
00074   if (strcmp(flag, "death_test_use_fork") == 0) {
00075     cout << GTEST_FLAG(death_test_use_fork);
00076     return;
00077   }
00078 
00079   if (strcmp(flag, "filter") == 0) {
00080     cout << GTEST_FLAG(filter);
00081     return;
00082   }
00083 
00084   if (strcmp(flag, "output") == 0) {
00085     cout << GTEST_FLAG(output);
00086     return;
00087   }
00088 
00089   if (strcmp(flag, "print_time") == 0) {
00090     cout << GTEST_FLAG(print_time);
00091     return;
00092   }
00093 
00094   if (strcmp(flag, "repeat") == 0) {
00095     cout << GTEST_FLAG(repeat);
00096     return;
00097   }
00098 
00099   if (strcmp(flag, "stack_trace_depth") == 0) {
00100     cout << GTEST_FLAG(stack_trace_depth);
00101     return;
00102   }
00103 
00104   if (strcmp(flag, "throw_on_failure") == 0) {
00105     cout << GTEST_FLAG(throw_on_failure);
00106     return;
00107   }
00108 
00109   cout << "Invalid flag name " << flag
00110        << ".  Valid names are break_on_failure, color, filter, etc.\n";
00111   exit(1);
00112 }
00113 
00114 }  // namespace testing
00115 
00116 int main(int argc, char** argv) {
00117   testing::InitGoogleTest(&argc, argv);
00118 
00119   if (argc != 2) {
00120     cout << "Usage: gtest_env_var_test_ NAME_OF_FLAG\n";
00121     return 1;
00122   }
00123 
00124   testing::PrintFlag(argv[1]);
00125   return 0;
00126 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:04