39 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ 40 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ 45 #include <type_traits> 59 # pragma warning(push) 60 # pragma warning(disable:4100) 61 # pragma warning(disable:4805) 78 template <
typename Po
inter>
82 typedef typename Pointer::element_type
type;
91 template <
typename Po
inter>
92 inline const typename Pointer::element_type*
GetRawPointer(
const Pointer&
p) {
96 template <
typename Element>
103 #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED) 106 # define GMOCK_WCHAR_T_IS_NATIVE_ 1 119 #if !defined(__WCHAR_UNSIGNED__) 121 # define GMOCK_HAS_SIGNED_WCHAR_T_ 1 140 #define GMOCK_DECLARE_KIND_(type, kind) \ 141 template <> struct KindOf<type> { enum { value = kind }; } 156 #if GMOCK_WCHAR_T_IS_NATIVE_ 169 #undef GMOCK_DECLARE_KIND_ 172 #define GMOCK_KIND_OF_(type) \ 173 static_cast< ::testing::internal::TypeKind>( \ 174 ::testing::internal::KindOf<type>::value) 177 #define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0) 188 template <TypeKind kFromKind,
typename From, TypeKind kToKind,
typename To>
197 template <
typename To>
202 template <
typename To>
207 template <
typename From>
213 template <
typename From,
typename To>
218 ((sizeof(From) < sizeof(To)) &&
219 (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
221 ((sizeof(From) == sizeof(To)) &&
222 (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {};
224 #undef GMOCK_IS_SIGNED_
228 template <typename From, typename To>
229 struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
230 : public false_type {};
233 template <typename From>
234 struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
235 : public false_type {};
238 template <typename From, typename To>
239 struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
240 : public false_type {};
244 template <typename From, typename To>
245 struct LosslessArithmeticConvertibleImpl<
246 kFloatingPoint, From, kFloatingPoint, To>
247 : public bool_constant<sizeof(From) <= sizeof(To)> {};
256 template <typename From, typename To>
257 struct LosslessArithmeticConvertible
258 : public LosslessArithmeticConvertibleImpl<
259 GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {};
263 class FailureReporterInterface {
270 virtual ~FailureReporterInterface() {}
273 virtual void ReportFailure(FailureType type, const char* file, int line,
274 const std::string& message) = 0;
278 GTEST_API_ FailureReporterInterface* GetFailureReporter();
285 inline void Assert(bool condition, const char* file, int line,
286 const std::string& msg) {
288 GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
292 inline void Assert(bool condition, const char* file, int line) {
293 Assert(condition, file, line, "Assertion failed.");
298 inline void Expect(bool condition, const char* file, int line,
299 const std::string& msg) {
301 GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,
305 inline void
Expect(bool condition, const char* file, int line) {
306 Expect(condition, file, line,
"Expectation failed.");
336 int stack_frames_to_skip);
383 # pragma warning(push) 384 # pragma warning(disable:4717) 392 template <
typename T>
394 Assert(
false,
"", -1,
"Internal error: attempt to return invalid value");
402 # pragma warning(pop) 421 template <
class RawContainer>
433 static type
Copy(
const RawContainer& container) {
return container; }
437 template <
typename Element,
size_t N>
451 testing::StaticAssertTypeEq<Element, RawElement>();
454 static type
Copy(
const Element (&array)[N]) {
461 template <
typename ElementPo
inter,
typename Size>
470 const ::std::tuple<ElementPointer, Size>& array) {
471 return type(std::get<0>(array), std::get<1>(array),
474 static type
Copy(const ::std::tuple<ElementPointer, Size>& array) {
486 template <
typename T>
492 template <
typename K,
typename V>
499 template <
bool kValue>
509 template <
class Pack,
size_t I>
struct append;
510 template <
size_t... Is,
size_t I>
517 template <
typename F,
typename Tuple,
size_t... Idx>
519 std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) {
520 return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...);
524 template <
typename F,
typename Tuple>
526 -> decltype(
ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
528 return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
545 template <
typename T>
548 template <
typename R,
typename... Args>
551 static constexpr
size_t ArgumentCount =
sizeof...(Args);
561 template <
typename R,
typename... Args>
562 constexpr
size_t Function<R(Args...)>::ArgumentCount;
565 # pragma warning(pop) 571 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ const char * p
Definition: gmock-matchers_test.cc:3613
auto Apply(F &&f, Tuple &&args) -> decltype(ApplyImpl(std::forward< F >(f), std::forward< Tuple >(args), make_int_pack< std::tuple_size< Tuple >::value >()))
Definition: gmock-internal-utils.h:525
Definition: gmock-internal-utils.h:507
Definition: gmock-actions.h:59
Definition: gtest-internal.h:1086
GTEST_API_ void IllegalDoDefault(const char *file, int line)
Definition: gmock-internal-utils.cc:189
Definition: googletest-port-test.cc:192
internal::NativeArray< RawElement > type
Definition: gmock-internal-utils.h:466
tuple message
Definition: googletest-output-test.py:337
static const_reference ConstReference(const RawContainer &container)
Definition: gmock-internal-utils.h:427
Definition: gmock-internal-utils.h:131
Definition: gmock-internal-utils.h:344
Definition: gmock-internal-utils.h:369
Definition: gmock-internal-utils.h:487
T type
Definition: gmock-internal-utils.h:369
const type const_reference
Definition: gmock-internal-utils.h:467
T type
Definition: gmock-internal-utils.h:86
internal::NativeArray< RawElement > type
Definition: gmock-internal-utils.h:441
::std::vector< ::std::string > Strings
Definition: gtest-printers.h:871
Definition: gmock-internal-utils.h:79
Definition: gmock-internal-utils.h:500
auto ApplyImpl(F &&f, Tuple &&args, int_pack< Idx... >) -> decltype(std::forward< F >(f)(std::get< Idx >(std::forward< Tuple >(args))...))
Definition: gmock-internal-utils.h:518
Definition: gtest-internal.h:1193
#define GTEST_API_
Definition: gtest-port.h:759
std::tuple< Args... > ArgumentTuple
Definition: gmock-internal-utils.h:555
static type Copy(const ::std::tuple< ElementPointer, Size > &array)
Definition: gmock-internal-utils.h:474
static const_reference ConstReference(const Element(&array)[N])
Definition: gmock-internal-utils.h:449
const char kInfoVerbosity[]
Definition: gmock-internal-utils.h:318
const char kWarningVerbosity[]
Definition: gmock-internal-utils.h:320
Definition: gmock-internal-utils.h:422
usr bin c fPIC pthread std
Definition: link.txt:1
Definition: gmock-internal-utils.h:52
GTEST_API_ std::string ConvertIdentifierNameToWords(const char *id_name)
Definition: gmock-internal-utils.cc:72
TypeKind
Definition: gmock-internal-utils.h:130
GMOCK_DECLARE_KIND_(bool, kBool)
Definition: gmock-internal-utils.h:364
Definition: gmock-internal-utils.h:131
Definition: gmock-internal-utils.h:131
const type const_reference
Definition: gmock-internal-utils.h:447
const T * type
Definition: gmock-internal-utils.h:377
Definition: gmock-internal-utils.h:312
R Result
Definition: gmock-internal-utils.h:550
Definition: gmock-internal-utils.h:189
T type
Definition: gmock-internal-utils.h:364
void(Args...) MakeResultVoid
Definition: gmock-internal-utils.h:557
GTEST_API_ std::string JoinAsTuple(const Strings &fields)
Definition: gmock-internal-utils.cc:51
Definition: gmock-internal-utils.h:509
Definition: gmock-internal-utils.h:135
Definition: gtest-internal.h:1172
Definition: gmock-internal-utils.h:356
Definition: gtest-port.h:1925
T type
Definition: gmock-internal-utils.h:365
LogSeverity
Definition: gmock-internal-utils.h:310
Definition: gmock-internal-utils.h:514
const type & const_reference
Definition: gmock-internal-utils.h:425
GTEST_API_ bool LogIsVisible(LogSeverity severity)
Definition: gmock-internal-utils.cc:128
Pointer::element_type type
Definition: gmock-internal-utils.h:82
int value
Definition: gmock-matchers_test.cc:657
RawContainer type
Definition: gmock-internal-utils.h:424
Definition: gtest-internal.h:1074
void Assert(bool condition, const char *file, int line)
Definition: gmock-internal-utils.h:292
int_pack type
Definition: gmock-internal-utils.h:507
static type Copy(const RawContainer &container)
Definition: gmock-internal-utils.h:433
static const_reference ConstReference(const ::std::tuple< ElementPointer, Size > &array)
Definition: gmock-internal-utils.h:469
const T * type
Definition: gmock-internal-utils.h:371
Definition: gmock-internal-utils.h:546
Definition: gtest-internal.h:1075
IgnoredValue(Args...) MakeResultIgnoredValue
Definition: gmock-internal-utils.h:558
Definition: gmock-internal-utils.h:311
std::pair< K, V > type
Definition: gmock-internal-utils.h:494
TypeWithSize< 8 >::UInt UInt64
Definition: gtest-port.h:2219
bool StaticAssertTypeEq()
Definition: gtest.h:2281
T Invalid()
Definition: gmock-internal-utils.h:393
static type Copy(const Element(&array)[N])
Definition: gmock-internal-utils.h:454
std::tuple< Matcher< Args >... > ArgumentMatcherTuple
Definition: gmock-internal-utils.h:556
#define GTEST_REMOVE_CONST_(T)
Definition: gtest-internal.h:890
TypeWithSize< 8 >::Int Int64
Definition: gtest-port.h:2218
Definition: gmock-internal-utils.h:360
const char kErrorVerbosity[]
Definition: gmock-internal-utils.h:322
const Pointer::element_type * GetRawPointer(const Pointer &p)
Definition: gmock-internal-utils.h:92
void Expect(bool condition, const char *file, int line, const std::string &msg)
Definition: gmock-internal-utils.h:298
GTEST_API_ WithoutMatchers GetWithoutMatchers()
Definition: gmock-internal-utils.cc:187
Definition: gmock-internal-utils.h:131
T type
Definition: gmock-internal-utils.h:488
GTEST_API_ void Log(LogSeverity severity, const std::string &message, int stack_frames_to_skip)
Definition: gmock-internal-utils.cc:149
Definition: gtest-internal.h:110