Implements the --gtest_death_test_use_fork flag and StaticAssertTypeEq.
This commit is contained in:
@@ -1242,6 +1242,52 @@ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
||||
__FILE__, __LINE__, ::testing::Message() << (message))
|
||||
|
||||
namespace internal {
|
||||
|
||||
// This template is declared, but intentionally undefined.
|
||||
template <typename T1, typename T2>
|
||||
struct StaticAssertTypeEqHelper;
|
||||
|
||||
template <typename T>
|
||||
struct StaticAssertTypeEqHelper<T, T> {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Compile-time assertion for type equality.
|
||||
// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
|
||||
// the same type. The value it returns is not interesting.
|
||||
//
|
||||
// Instead of making StaticAssertTypeEq a class template, we make it a
|
||||
// function template that invokes a helper class template. This
|
||||
// prevents a user from misusing StaticAssertTypeEq<T1, T2> by
|
||||
// defining objects of that type.
|
||||
//
|
||||
// CAVEAT:
|
||||
//
|
||||
// When used inside a method of a class template,
|
||||
// StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is
|
||||
// instantiated. For example, given:
|
||||
//
|
||||
// template <typename T> class Foo {
|
||||
// public:
|
||||
// void Bar() { testing::StaticAssertTypeEq<int, T>(); }
|
||||
// };
|
||||
//
|
||||
// the code:
|
||||
//
|
||||
// void Test1() { Foo<bool> foo; }
|
||||
//
|
||||
// will NOT generate a compiler error, as Foo<bool>::Bar() is never
|
||||
// actually instantiated. Instead, you need:
|
||||
//
|
||||
// void Test2() { Foo<bool> foo; foo.Bar(); }
|
||||
//
|
||||
// to cause a compiler error.
|
||||
template <typename T1, typename T2>
|
||||
bool StaticAssertTypeEq() {
|
||||
internal::StaticAssertTypeEqHelper<T1, T2>();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Defines a test.
|
||||
//
|
||||
|
||||
@@ -46,6 +46,7 @@ GTEST_DECLARE_string_(internal_run_death_test);
|
||||
|
||||
// Names of the flags (needed for parsing Google Test flags).
|
||||
const char kDeathTestStyleFlag[] = "death_test_style";
|
||||
const char kDeathTestUseFork[] = "death_test_use_fork";
|
||||
const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
|
||||
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
// This header file declares classes and functions used internally by
|
||||
// Google Test. They are subject to change without notice.
|
||||
//
|
||||
// This file is #included in testing/base/internal/gtest-internal.h
|
||||
// This file is #included in <gtest/internal/gtest-internal.h>.
|
||||
// Do not include this header file separately!
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
// Google Test. They are subject to change without notice. They should not used
|
||||
// by code external to Google Test.
|
||||
//
|
||||
// This header file is #included by testing/base/internal/gtest-internal.h.
|
||||
// This header file is #included by <gtest/internal/gtest-internal.h>.
|
||||
// It should not be #included by other files.
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
|
||||
|
||||
Reference in New Issue
Block a user