From ba1c362cb05a57fe4f0d69e989eb5b0ca9f8cbb1 Mon Sep 17 00:00:00 2001 From: vladlosev Date: Tue, 29 Mar 2011 21:42:53 +0000 Subject: Allows Google Mock to compile on platforms that do not support typed tests. git-svn-id: http://googletest.googlecode.com/svn/trunk@557 861a406c-534a-0410-8894-cb66d6ee9925 --- include/gtest/internal/gtest-type-util.h | 34 ++++++++++++++------------- include/gtest/internal/gtest-type-util.h.pump | 34 ++++++++++++++------------- 2 files changed, 36 insertions(+), 32 deletions(-) (limited to 'include/gtest/internal') diff --git a/include/gtest/internal/gtest-type-util.h b/include/gtest/internal/gtest-type-util.h index 49b85ca..ec9315d 100644 --- a/include/gtest/internal/gtest-type-util.h +++ b/include/gtest/internal/gtest-type-util.h @@ -47,8 +47,6 @@ #include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-string.h" -#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P - // #ifdef __GNUC__ is too general here. It is possible to use gcc without using // libstdc++ (which is where cxxabi.h comes from). # ifdef __GLIBCXX__ @@ -58,19 +56,9 @@ namespace testing { namespace internal { -// AssertyTypeEq::type is defined iff T1 and T2 are the same -// type. This can be used as a compile-time assertion to ensure that -// two types are equal. - -template -struct AssertTypeEq; - -template -struct AssertTypeEq { - typedef bool type; -}; - // GetTypeName() returns a human-readable name of type T. +// NB: This function is also used in Google Mock, so don't move it inside of +// the typed-test-only section below. template String GetTypeName() { # if GTEST_HAS_RTTI @@ -95,6 +83,20 @@ String GetTypeName() { # endif // GTEST_HAS_RTTI } +#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// AssertyTypeEq::type is defined iff T1 and T2 are the same +// type. This can be used as a compile-time assertion to ensure that +// two types are equal. + +template +struct AssertTypeEq; + +template +struct AssertTypeEq { + typedef bool type; +}; + // A unique type used as the default value for the arguments of class // template Types. This allows us to simulate variadic templates // (e.g. Types, Type, and etc), which C++ doesn't @@ -3315,9 +3317,9 @@ struct TypeList::type type; }; +#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + } // namespace internal } // namespace testing -#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P - #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ diff --git a/include/gtest/internal/gtest-type-util.h.pump b/include/gtest/internal/gtest-type-util.h.pump index 0caab21..b69ce6e 100644 --- a/include/gtest/internal/gtest-type-util.h.pump +++ b/include/gtest/internal/gtest-type-util.h.pump @@ -45,8 +45,6 @@ $var n = 50 $$ Maximum length of type lists we want to support. #include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-string.h" -#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P - // #ifdef __GNUC__ is too general here. It is possible to use gcc without using // libstdc++ (which is where cxxabi.h comes from). # ifdef __GLIBCXX__ @@ -56,19 +54,9 @@ $var n = 50 $$ Maximum length of type lists we want to support. namespace testing { namespace internal { -// AssertyTypeEq::type is defined iff T1 and T2 are the same -// type. This can be used as a compile-time assertion to ensure that -// two types are equal. - -template -struct AssertTypeEq; - -template -struct AssertTypeEq { - typedef bool type; -}; - // GetTypeName() returns a human-readable name of type T. +// NB: This function is also used in Google Mock, so don't move it inside of +// the typed-test-only section below. template String GetTypeName() { # if GTEST_HAS_RTTI @@ -93,6 +81,20 @@ String GetTypeName() { # endif // GTEST_HAS_RTTI } +#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// AssertyTypeEq::type is defined iff T1 and T2 are the same +// type. This can be used as a compile-time assertion to ensure that +// two types are equal. + +template +struct AssertTypeEq; + +template +struct AssertTypeEq { + typedef bool type; +}; + // A unique type used as the default value for the arguments of class // template Types. This allows us to simulate variadic templates // (e.g. Types, Type, and etc), which C++ doesn't @@ -281,9 +283,9 @@ struct TypeList > { typedef typename Types<$for i, [[T$i]]>::type type; }; +#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + } // namespace internal } // namespace testing -#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P - #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ -- cgit v1.2.3