38 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ 39 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ 47 #include "gtest/gtest.h" 64 template <
typename Po
inter>
69 typedef typename Pointer::element_type
type;
78 template <
typename Po
inter>
79 inline const typename Pointer::element_type *
GetRawPointer(
const Pointer & p)
84 template <
typename Element>
91 bool operator()(const ::testing::internal::linked_ptr<T> & lhs,
92 const ::testing::internal::linked_ptr<T> & rhs)
const 94 return lhs.get() < rhs.get();
106 #if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \ 107 (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)) 110 # define GMOCK_WCHAR_T_IS_NATIVE_ 1 124 # define GMOCK_HAS_SIGNED_WCHAR_T_ 1 138 template <
typename T>
struct KindOf 140 enum { value = kOther };
144 #define GMOCK_DECLARE_KIND_(type, kind) \ 145 template <> struct KindOf<type> { enum { value = kind }; } 160 #if GMOCK_WCHAR_T_IS_NATIVE_ 173 #undef GMOCK_DECLARE_KIND_ 176 #define GMOCK_KIND_OF_(type) \ 177 static_cast< ::testing::internal::TypeKind>( \ 178 ::testing::internal::KindOf<type>::value) 181 #define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0) 192 template <TypeKind kFromKind,
typename From, TypeKind kToKind,
typename To>
193 struct LosslessArithmeticConvertibleImpl :
public false_type {};
197 struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool>
201 template <
typename To>
202 struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To>
206 template <
typename To>
207 struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To>
211 template <
typename From>
212 struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
217 template <
typename From,
typename To>
218 struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
219 :
public bool_constant <
222 ((sizeof(From) < sizeof(To)) &&
223 (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
225 ((sizeof(From) == sizeof(To)) &&
226 (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To))) > {};
228 #undef GMOCK_IS_SIGNED_
232 template <typename From, typename To>
233 struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
234 : public false_type {};
237 template <typename From>
238 struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
239 : public false_type {};
242 template <typename From, typename To>
243 struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
244 : public false_type {};
248 template <typename From, typename To>
249 struct LosslessArithmeticConvertibleImpl <
250 kFloatingPoint, From, kFloatingPoint, To >
251 : public bool_constant < sizeof(From) <= sizeof(To) > {};
260 template <typename From, typename To>
261 struct LosslessArithmeticConvertible
262 : public LosslessArithmeticConvertibleImpl <
263 GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To > {};
267 class FailureReporterInterface
276 virtual ~FailureReporterInterface() {}
279 virtual void ReportFailure(FailureType type, const char * file, int line,
280 const string & message) = 0;
284 GTEST_API_ FailureReporterInterface * GetFailureReporter();
291 inline void Assert(bool condition, const char * file, int line,
296 GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
300 inline void Assert(bool condition, const char * file, int line)
302 Assert(condition, file, line, "Assertion failed.");
307 inline void Expect(bool condition, const char * file, int line,
312 GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,
316 inline void
Expect(bool condition, const char * file, int line)
318 Expect(condition, file, line,
"Expectation failed.");
350 int stack_frames_to_skip);
371 template <
typename T,
size_t N>
struct DecayArray<T[N]>
387 template <
typename T>
412 template <
class RawContainer>
426 static type
Copy(
const RawContainer & container) {
return container; }
430 template <
typename Element,
size_t N>
446 testing::StaticAssertTypeEq<Element, RawElement>();
464 #endif // GTEST_OS_SYMBIAN 466 static type
Copy(
const Element(&array)[N])
469 return type(const_cast<Element *>(&array[0]), N,
kCopy);
472 #endif // GTEST_OS_SYMBIAN 478 template <
typename ElementPo
inter,
typename Size>
488 const ::std::tr1::tuple<ElementPointer, Size> & array)
493 static type
Copy(const ::std::tr1::tuple<ElementPointer, Size> & array)
496 return type(get<0>(array), get<1>(array),
kCopy);
507 template <
typename T>
514 template <
typename K,
typename V>
522 template <
bool kValue>
528 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
TypeWithSize< 8 >::Int Int64
internal::NativeArray< RawElement > type
GTEST_API_ string ConvertIdentifierNameToWords(const char *id_name)
static const_reference ConstReference(const ::std::tr1::tuple< ElementPointer, Size > &array)
static type Copy(const ::std::tr1::tuple< ElementPointer, Size > &array)
const char kErrorVerbosity[]
static const_reference ConstReference(const RawContainer &container)
internal::NativeArray< RawElement > type
TypeWithSize< 8 >::UInt UInt64
static const_reference ConstReference(const Element(&array)[N])
const char kInfoVerbosity[]
bool_constant< true > true_type
GMOCK_DECLARE_KIND_(bool, kBool)
const type const_reference
void Expect(bool condition, const char *file, int line, const string &msg)
const char kWarningVerbosity[]
const type const_reference
GTEST_API_ void Log(LogSeverity severity, const string &message, int stack_frames_to_skip)
bool operator()(const ::testing::internal::linked_ptr< T > &lhs, const ::testing::internal::linked_ptr< T > &rhs) const
const type & const_reference
GTEST_API_ bool LogIsVisible(LogSeverity severity)
Pointer::element_type type
static type Copy(const RawContainer &container)
#define GTEST_REMOVE_CONST_(T)
const Pointer::element_type * GetRawPointer(const Pointer &p)
bool_constant< false > false_type
bool StaticAssertTypeEq()
static type Copy(const Element(&array)[N])