39 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ 40 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ 45 #include <type_traits> 46 #include "gmock/internal/gmock-port.h" 47 #include "gtest/gtest.h" 59 # pragma warning(push) 60 # pragma warning(disable:4100) 61 # pragma warning(disable:4805) 66 GTEST_API_ std::string JoinAsTuple(
const Strings& fields);
72 GTEST_API_ std::string ConvertIdentifierNameToWords(
const char* id_name);
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>
97 inline Element* GetRawPointer(Element* p) {
return p; }
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 131 kBool, kInteger, kFloatingPoint, kOther
136 enum { value = kOther };
140 #define GMOCK_DECLARE_KIND_(type, kind) \ 141 template <> struct KindOf<type> { enum { value = kind }; } 143 GMOCK_DECLARE_KIND_(
bool, kBool);
146 GMOCK_DECLARE_KIND_(
char, kInteger);
147 GMOCK_DECLARE_KIND_(
signed char, kInteger);
148 GMOCK_DECLARE_KIND_(
unsigned char, kInteger);
149 GMOCK_DECLARE_KIND_(
short, kInteger);
150 GMOCK_DECLARE_KIND_(
unsigned short, kInteger);
151 GMOCK_DECLARE_KIND_(
int, kInteger);
152 GMOCK_DECLARE_KIND_(
unsigned int, kInteger);
153 GMOCK_DECLARE_KIND_(
long, kInteger);
154 GMOCK_DECLARE_KIND_(
unsigned long, kInteger);
156 #if GMOCK_WCHAR_T_IS_NATIVE_ 157 GMOCK_DECLARE_KIND_(
wchar_t, kInteger);
161 GMOCK_DECLARE_KIND_(Int64, kInteger);
162 GMOCK_DECLARE_KIND_(UInt64, kInteger);
165 GMOCK_DECLARE_KIND_(
float, kFloatingPoint);
166 GMOCK_DECLARE_KIND_(
double, kFloatingPoint);
167 GMOCK_DECLARE_KIND_(
long double, kFloatingPoint);
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.");
318 const char kInfoVerbosity[] =
"info";
320 const char kWarningVerbosity[] =
"warning";
322 const char kErrorVerbosity[] =
"error";
326 GTEST_API_
bool LogIsVisible(LogSeverity severity);
335 GTEST_API_
void Log(LogSeverity severity,
const std::string& message,
336 int stack_frames_to_skip);
371 typedef const T* type;
377 typedef const T* type;
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>
424 typedef RawContainer type;
425 typedef const type& const_reference;
427 static const_reference ConstReference(
const RawContainer& container) {
429 testing::StaticAssertTypeEq<RawContainer,
430 GTEST_REMOVE_CONST_(RawContainer)>();
433 static type Copy(
const RawContainer& container) {
return container; }
437 template <
typename Element,
size_t N>
440 typedef GTEST_REMOVE_CONST_(Element) RawElement;
449 static const_reference ConstReference(
const Element (&array)[N]) {
451 testing::StaticAssertTypeEq<Element, RawElement>();
454 static type Copy(
const Element (&array)[N]) {
461 template <
typename ElementPo
inter,
typename Size>
464 typedef GTEST_REMOVE_CONST_(
465 typename internal::PointeeOf<ElementPointer>::type) RawElement;
469 static const_reference ConstReference(
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>
494 typedef std::pair<K, V> type;
499 template <
bool kValue>
504 GTEST_API_
void IllegalDoDefault(
const char* file,
int line);
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>
525 auto Apply(F&& f, Tuple&& args)
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);
555 using ArgumentTuple = std::tuple<Args...>;
557 using MakeResultVoid =
void(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_ Definition: gmock-internal-utils.h:507
Definition: gmock-actions.h:59
Definition: gtest-internal.h:1114
Definition: googletest-port-test.cc:192
Definition: gmock-internal-utils.h:344
Definition: gmock-internal-utils.h:369
Definition: gmock-internal-utils.h:487
Definition: gmock-internal-utils.h:79
Definition: gmock-internal-utils.h:500
Definition: gtest-internal.h:1221
Definition: gmock-internal-utils.h:422
Definition: gmock-internal-utils.h:52
Definition: gmock-internal-utils.h:364
Definition: gmock-internal-utils.h:189
Definition: gmock-internal-utils.h:509
Definition: gmock-internal-utils.h:135
Definition: gtest-internal.h:1200
Definition: gmock-internal-utils.h:356
Definition: gtest-port.h:1950
Definition: gmock-internal-utils.h:514
Definition: gtest-internal.h:1102
Definition: gmock-internal-utils.h:546
Definition: gtest-internal.h:1103
Definition: gmock-internal-utils.h:360
Definition: gtest-internal.h:111