38#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
39#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
55# pragma warning(disable:4100)
56# pragma warning(disable:4805)
73template <
typename Po
inter>
77 typedef typename Pointer::element_type
type;
86template <
typename Po
inter>
91template <
typename Element>
97 bool operator()(const ::testing::internal::linked_ptr<T>& lhs,
98 const ::testing::internal::linked_ptr<T>& rhs)
const {
99 return lhs.get() < rhs.get();
111#if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \
112 (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
115# define GMOCK_WCHAR_T_IS_NATIVE_ 1
128#if !defined(__WCHAR_UNSIGNED__)
130# define GMOCK_HAS_SIGNED_WCHAR_T_ 1
149#define GMOCK_DECLARE_KIND_(type, kind) \
150 template <> struct KindOf<type> { enum { value = kind }; }
165#if GMOCK_WCHAR_T_IS_NATIVE_
178#undef GMOCK_DECLARE_KIND_
181#define GMOCK_KIND_OF_(type) \
182 static_cast< ::testing::internal::TypeKind>( \
183 ::testing::internal::KindOf<type>::value)
186#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
197template <TypeKind kFromKind,
typename From, TypeKind kToKind,
typename To>
206template <
typename To>
211template <
typename To>
216template <
typename From>
222template <
typename From,
typename To>
227 ((sizeof(From) < sizeof(To)) &&
228 (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
230 ((sizeof(From) == sizeof(To)) &&
231 (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {};
233#undef GMOCK_IS_SIGNED_
237template <typename From, typename To>
238struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
239 : public false_type {};
242template <typename From>
243struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
244 : public false_type {};
247template <typename From, typename To>
248struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
249 : public false_type {};
253template <typename From, typename To>
254struct LosslessArithmeticConvertibleImpl<
255 kFloatingPoint, From, kFloatingPoint, To>
256 : public bool_constant<sizeof(From) <= sizeof(To)> {};
265template <typename From, typename To>
266struct LosslessArithmeticConvertible
267 : public LosslessArithmeticConvertibleImpl<
268 GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {};
272class FailureReporterInterface {
279 virtual ~FailureReporterInterface() {}
282 virtual void ReportFailure(FailureType type, const char* file, int line,
283 const std::string& message) = 0;
287GTEST_API_ FailureReporterInterface* GetFailureReporter();
294inline void Assert(bool condition, const char* file, int line,
295 const std::string& msg) {
297 GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
301inline void Assert(bool condition, const char* file, int line) {
302 Assert(condition, file, line, "Assertion failed.");
307inline void Expect(bool condition, const char* file, int line,
308 const std::string& msg) {
310 GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,
314inline void
Expect(bool condition, const char* file, int line) {
315 Expect(condition, file, line,
"Expectation failed.");
327const char kInfoVerbosity[] =
"info";
329const char kWarningVerbosity[] =
"warning";
331const char kErrorVerbosity[] =
"error";
345 int stack_frames_to_skip);
394# pragma warning(push)
395# pragma warning(disable:4717)
405 Assert(
false,
"", -1,
"Internal error: attempt to return invalid value");
432template <
class RawContainer>
444 static type Copy(
const RawContainer& container) {
return container; }
448template <
typename Element,
size_t N>
477 return type(
const_cast<Element*
>(&array[0]),
N,
494template <
typename ElementPo
inter,
typename Size>
503 const ::testing::tuple<ElementPointer, Size>& array) {
506 static type Copy(const ::testing::tuple<ElementPointer, Size>& array) {
513template <
typename T>
class StlContainerView<
T&>;
524template <
typename K,
typename V>
531template <
bool kValue>
540template <
size_t... Is>
struct int_pack {
typedef int_pack
type; };
542template <
class Pack,
size_t I>
struct append;
543template <
size_t... Is,
size_t I>
544struct append<int_pack<Is...>, I> : int_pack<Is..., I> {};
547struct make_int_pack : append<typename make_int_pack<C - 1>::type, C - 1> {};
548template <>
struct make_int_pack<0> : int_pack<> {};
550template <
typename F,
typename Tuple,
size_t... Idx>
551auto ApplyImpl(F&&
f, Tuple&& args, int_pack<Idx...>) ->
decltype(
552 std::forward<F>(
f)(std::get<Idx>(std::forward<Tuple>(args))...)) {
553 return std::forward<F>(
f)(std::get<Idx>(std::forward<Tuple>(args))...);
557template <
typename F,
typename Tuple>
558auto Apply(F&&
f, Tuple&& args)
559 ->
decltype(ApplyImpl(std::forward<F>(
f), std::forward<Tuple>(args),
560 make_int_pack<std::tuple_size<Tuple>::value>())) {
561 return ApplyImpl(std::forward<F>(
f), std::forward<Tuple>(args),
562 make_int_pack<std::tuple_size<Tuple>::value>());
Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.
typedef GTEST_REMOVE_CONST_(typename internal::PointeeOf< ElementPointer >::type) RawElement
static type Copy(const ::testing::tuple< ElementPointer, Size > &array)
internal::NativeArray< RawElement > type
static const_reference ConstReference(const ::testing::tuple< ElementPointer, Size > &array)
const type const_reference
const type const_reference
static const_reference ConstReference(const Element(&array)[N])
static type Copy(const Element(&array)[N])
typedef GTEST_REMOVE_CONST_(Element) RawElement
internal::NativeArray< RawElement > type
static const_reference ConstReference(const RawContainer &container)
static type Copy(const RawContainer &container)
const type & const_reference
friend GTEST_API_ WithoutMatchers GetWithoutMatchers()
#define GMOCK_DECLARE_KIND_(type, kind)
#define GTEST_REMOVE_CONST_(T)
GTEST_API_ std::string ConvertIdentifierNameToWords(const char *id_name)
TypeWithSize< 8 >::Int Int64
GTEST_API_ std::string JoinAsTuple(const Strings &fields)
::std::vector< ::std::string > Strings
GTEST_API_ bool LogIsVisible(LogSeverity severity)
void Assert(bool condition, const char *file, int line)
GTEST_API_ void IllegalDoDefault(const char *file, int line)
TypeWithSize< 8 >::UInt UInt64
GTEST_API_ WithoutMatchers GetWithoutMatchers()
const Pointer::element_type * GetRawPointer(const Pointer &p)
void Expect(bool condition, const char *file, int line, const std::string &msg)
bool StaticAssertTypeEq()
#define T(meth, val, expected)
bool operator()(const ::testing::internal::linked_ptr< T > &lhs, const ::testing::internal::linked_ptr< T > &rhs) const
Pointer::element_type type