Adds a TestInfo to the unit test. Arguments: set_up_tc: pointer to the function that sets up the test case tear_down_tc: pointer to the function that tears down the test case test_info: the TestInfo object
| 1028 | // tear_down_tc: pointer to the function that tears down the test case |
| 1029 | // test_info: the TestInfo object |
| 1030 | void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc, |
| 1031 | Test::TearDownTestCaseFunc tear_down_tc, |
| 1032 | TestInfo* test_info) { |
| 1033 | // In order to support thread-safe death tests, we need to |
| 1034 | // remember the original working directory when the test program |
| 1035 | // was first invoked. We cannot do this in RUN_ALL_TESTS(), as |
| 1036 | // the user may have changed the current directory before calling |
| 1037 | // RUN_ALL_TESTS(). Therefore we capture the current directory in |
| 1038 | // AddTestInfo(), which is called to register a TEST or TEST_F |
| 1039 | // before main() is reached. |
| 1040 | if (original_working_dir_.IsEmpty()) { |
| 1041 | original_working_dir_.Set(FilePath::GetCurrentDir()); |
| 1042 | GTEST_CHECK_(!original_working_dir_.IsEmpty()) |
| 1043 | << "Failed to get the current working directory."; |
| 1044 | } |
| 1045 | |
| 1046 | GetTestCase(test_info->test_case_name(), |
| 1047 | test_info->type_param(), |
| 1048 | set_up_tc, |
| 1049 | tear_down_tc)->AddTestInfo(test_info); |
| 1050 | } |
| 1051 | |
| 1052 | #if GTEST_HAS_PARAM_TEST |
| 1053 | // Returns ParameterizedTestCaseRegistry object used to keep track of |
nothing calls this directly
no test coverage detected