Modifications to improve portability of googletest tests.
PiperOrigin-RevId: 603034597 Change-Id: I4d716ed67f80f41075bfa266d975460d2ac27eb6
This commit is contained in:
		
				
					committed by
					
						
						Copybara-Service
					
				
			
			
				
	
			
			
			
						parent
						
							6fdb4c303f
						
					
				
				
					commit
					456574145c
				
			@@ -115,11 +115,14 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
 | 
				
			|||||||
      strcasecmp("gtest_dll_test", exe_str.c_str()) == 0;
 | 
					      strcasecmp("gtest_dll_test", exe_str.c_str()) == 0;
 | 
				
			||||||
#elif defined(GTEST_OS_FUCHSIA)
 | 
					#elif defined(GTEST_OS_FUCHSIA)
 | 
				
			||||||
  const bool success = exe_str == "app";
 | 
					  const bool success = exe_str == "app";
 | 
				
			||||||
 | 
					#elif defined(__EMSCRIPTEN__)
 | 
				
			||||||
 | 
					  const bool success = exe_str == "patched_googletest-options-test.js";
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
  const bool success =
 | 
					  const bool success =
 | 
				
			||||||
      exe_str == "googletest-options-test" || exe_str == "gtest_all_test" ||
 | 
					      exe_str == "googletest-options-test" || exe_str == "gtest_all_test" ||
 | 
				
			||||||
      exe_str == "lt-gtest_all_test" || exe_str == "gtest_dll_test";
 | 
					      exe_str == "lt-gtest_all_test" || exe_str == "gtest_dll_test";
 | 
				
			||||||
#endif  // GTEST_OS_WINDOWS
 | 
					#endif  // platform ifdefs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str;
 | 
					  if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -422,11 +422,14 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {
 | 
				
			|||||||
  EXPECT_EQ("-1234567.89", FormatTimeInMillisAsSeconds(-1234567890));
 | 
					  EXPECT_EQ("-1234567.89", FormatTimeInMillisAsSeconds(-1234567890));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: b/287046337 - In emscripten, local time zone modification is not
 | 
				
			||||||
 | 
					// supported.
 | 
				
			||||||
 | 
					#if !defined(__EMSCRIPTEN__)
 | 
				
			||||||
// Tests FormatEpochTimeInMillisAsIso8601().  The correctness of conversion
 | 
					// Tests FormatEpochTimeInMillisAsIso8601().  The correctness of conversion
 | 
				
			||||||
// for particular dates below was verified in Python using
 | 
					// for particular dates below was verified in Python using
 | 
				
			||||||
// datetime.datetime.fromutctimestamp(<timestamp>/1000).
 | 
					// datetime.datetime.fromutctimestamp(<timestamp>/1000).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// FormatEpochTimeInMillisAsIso8601 depends on the current timezone, so we
 | 
					// FormatEpochTimeInMillisAsIso8601 depends on the local timezone, so we
 | 
				
			||||||
// have to set up a particular timezone to obtain predictable results.
 | 
					// have to set up a particular timezone to obtain predictable results.
 | 
				
			||||||
class FormatEpochTimeInMillisAsIso8601Test : public Test {
 | 
					class FormatEpochTimeInMillisAsIso8601Test : public Test {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
@@ -445,9 +448,8 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    GTEST_DISABLE_MSC_DEPRECATED_POP_()
 | 
					    GTEST_DISABLE_MSC_DEPRECATED_POP_()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use.  We
 | 
					    // Set the local time zone for FormatEpochTimeInMillisAsIso8601 to be
 | 
				
			||||||
    // cannot use the local time zone because the function's output depends
 | 
					    // a fixed time zone for reproducibility purposes.
 | 
				
			||||||
    // on the time zone.
 | 
					 | 
				
			||||||
    SetTimeZone("UTC+00");
 | 
					    SetTimeZone("UTC+00");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -514,6 +516,8 @@ TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {
 | 
				
			|||||||
  EXPECT_EQ("1970-01-01T00:00:00.000", FormatEpochTimeInMillisAsIso8601(0));
 | 
					  EXPECT_EQ("1970-01-01T00:00:00.000", FormatEpochTimeInMillisAsIso8601(0));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  // __EMSCRIPTEN__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __BORLANDC__
 | 
					#ifdef __BORLANDC__
 | 
				
			||||||
// Silences warnings: "Condition is always true", "Unreachable code"
 | 
					// Silences warnings: "Condition is always true", "Unreachable code"
 | 
				
			||||||
#pragma option push -w-ccc -w-rch
 | 
					#pragma option push -w-ccc -w-rch
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user