X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftesting%2Fgmock%2Finclude%2Fgmock%2Finternal%2Fgmock-internal-utils.h;h=e2ddb05c91d7c02d7e076f32ba92fce2a4e940aa;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=f9b6b809fa8acf1d9376e2b6edfbf7d3001eff2d;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/testing/gmock/include/gmock/internal/gmock-internal-utils.h b/src/testing/gmock/include/gmock/internal/gmock-internal-utils.h index f9b6b80..e2ddb05 100644 --- a/src/testing/gmock/include/gmock/internal/gmock-internal-utils.h +++ b/src/testing/gmock/include/gmock/internal/gmock-internal-utils.h @@ -361,17 +361,30 @@ template struct DecayArray { typedef const T* type; }; -// Invalid() returns an invalid value of type T. This is useful +// Disable MSVC warnings for infinite recursion, since in this case the +// the recursion is unreachable. +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4717) +#endif + +// Invalid() is usable as an expression of type T, but will terminate +// the program with an assertion failure if actually run. This is useful // when a value of type T is needed for compilation, but the statement // will not really be executed (or we don't care if the statement // crashes). template inline T Invalid() { - return const_cast::type&>( - *static_cast::type*>(NULL)); + Assert(false, "", -1, "Internal error: attempt to return invalid value"); + // This statement is unreachable, and would never terminate even if it + // could be reached. It is provided only to placate compiler warnings + // about missing return statements. + return Invalid(); } -template <> -inline void Invalid() {} + +#ifdef _MSC_VER +# pragma warning(pop) +#endif // Given a raw type (i.e. having no top-level reference or const // modifier) RawContainer that's either an STL-style container or a @@ -434,16 +447,17 @@ class StlContainerView { // ConstReference(const char * (&)[4])') // (and though the N parameter type is mismatched in the above explicit // conversion of it doesn't help - only the conversion of the array). - return type(const_cast(&array[0]), N, kReference); + return type(const_cast(&array[0]), N, + RelationToSourceReference()); #else - return type(array, N, kReference); + return type(array, N, RelationToSourceReference()); #endif // GTEST_OS_SYMBIAN } static type Copy(const Element (&array)[N]) { #if GTEST_OS_SYMBIAN - return type(const_cast(&array[0]), N, kCopy); + return type(const_cast(&array[0]), N, RelationToSourceCopy()); #else - return type(array, N, kCopy); + return type(array, N, RelationToSourceCopy()); #endif // GTEST_OS_SYMBIAN } }; @@ -451,7 +465,7 @@ class StlContainerView { // This specialization is used when RawContainer is a native array // represented as a (pointer, size) tuple. template -class StlContainerView< ::std::tr1::tuple > { +class StlContainerView< ::testing::tuple > { public: typedef GTEST_REMOVE_CONST_( typename internal::PointeeOf::type) RawElement; @@ -459,13 +473,11 @@ class StlContainerView< ::std::tr1::tuple > { typedef const type const_reference; static const_reference ConstReference( - const ::std::tr1::tuple& array) { - using ::std::tr1::get; - return type(get<0>(array), get<1>(array), kReference); + const ::testing::tuple& array) { + return type(get<0>(array), get<1>(array), RelationToSourceReference()); } - static type Copy(const ::std::tr1::tuple& array) { - using ::std::tr1::get; - return type(get<0>(array), get<1>(array), kCopy); + static type Copy(const ::testing::tuple& array) { + return type(get<0>(array), get<1>(array), RelationToSourceCopy()); } }; @@ -473,6 +485,20 @@ class StlContainerView< ::std::tr1::tuple > { // StlContainer with a reference type. template class StlContainerView; +// A type transform to remove constness from the first part of a pair. +// Pairs like that are used as the value_type of associative containers, +// and this transform produces a similar but assignable pair. +template +struct RemoveConstFromKey { + typedef T type; +}; + +// Partially specialized to remove constness from std::pair. +template +struct RemoveConstFromKey > { + typedef std::pair type; +}; + // Mapping from booleans to types. Similar to boost::bool_ and // std::integral_constant. template @@ -482,3 +508,4 @@ struct BooleanConstant {}; } // namespace testing #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ +