39 #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ 40 #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ 46 #include <type_traits> 63 #pragma warning(disable : 4100) 64 #pragma warning(disable : 4805) 70 const std::vector<const char*>& names,
const Strings& values);
81 template <
typename Po
inter>
82 inline const typename Pointer::element_type*
GetRawPointer(
const Pointer& p) {
87 template <
typename Element>
93 template <
typename Element>
102 #define GMOCK_INTERNAL_WARNING_PUSH() 103 #define GMOCK_INTERNAL_WARNING_CLANG(Level, Name) 104 #define GMOCK_INTERNAL_WARNING_POP() 106 #if defined(__clang__) 107 #undef GMOCK_INTERNAL_WARNING_PUSH 108 #define GMOCK_INTERNAL_WARNING_PUSH() _Pragma("clang diagnostic push") 109 #undef GMOCK_INTERNAL_WARNING_CLANG 110 #define GMOCK_INTERNAL_WARNING_CLANG(Level, Warning) \ 111 _Pragma(GMOCK_PP_INTERNAL_STRINGIZE(clang diagnostic Level Warning)) 112 #undef GMOCK_INTERNAL_WARNING_POP 113 #define GMOCK_INTERNAL_WARNING_POP() _Pragma("clang diagnostic pop") 120 #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED) 123 #define GMOCK_WCHAR_T_IS_NATIVE_ 1 134 template <
typename T>
140 #define GMOCK_DECLARE_KIND_(type, kind) \ 142 struct KindOf<type> { \ 143 enum { value = kind }; \ 161 #if GMOCK_WCHAR_T_IS_NATIVE_ 170 #undef GMOCK_DECLARE_KIND_ 173 #define GMOCK_KIND_OF_(type) \ 174 static_cast< ::testing::internal::TypeKind>( \ 175 ::testing::internal::KindOf<type>::value) 186 template <TypeKind kFromKind,
typename From, TypeKind kToKind,
typename To>
191 (kFromKind ==
kBool) ?
true 194 : (kFromKind != kToKind) ? false
198 (((
sizeof(From) <
sizeof(To)) &&
199 !(std::is_signed<From>::value && !std::is_signed<To>::value)) ||
202 ((
sizeof(From) ==
sizeof(To)) &&
203 (std::is_signed<From>::value == std::is_signed<To>::value)))
207 : (kFromKind ==
kFloatingPoint && (
sizeof(From) <=
sizeof(To))) ? true
219 template <
typename From,
typename To>
234 virtual void ReportFailure(
FailureType type,
const char* file,
int line,
235 const std::string& message) = 0;
246 inline void Assert(
bool condition,
const char* file,
int line,
247 const std::string& msg) {
253 inline void Assert(
bool condition,
const char* file,
int line) {
254 Assert(condition, file, line,
"Assertion failed.");
259 inline void Expect(
bool condition,
const char* file,
int line,
260 const std::string& msg) {
266 inline void Expect(
bool condition,
const char* file,
int line) {
267 Expect(condition, file, line,
"Expectation failed.");
294 int stack_frames_to_skip);
316 template <
typename T>
318 Assert(
false,
"", -1,
"Internal error: attempt to return invalid value");
319 #if defined(__GNUC__) || defined(__clang__) 320 __builtin_unreachable();
321 #elif defined(_MSC_VER) 344 template <
class RawContainer>
351 static_assert(!std::is_const<RawContainer>::value,
352 "RawContainer type must not be const");
355 static type
Copy(
const RawContainer& container) {
return container; }
359 template <
typename Element,
size_t N>
372 static_assert(std::is_same<Element, RawElement>::value,
373 "Element type must not be const");
383 template <
typename ElementPo
inter,
typename Size>
386 typedef typename std::remove_const<
387 typename std::pointer_traits<ElementPointer>::element_type>
::type 393 const ::std::tuple<ElementPointer, Size>& array) {
394 return type(std::get<0>(array), std::get<1>(array),
397 static type
Copy(const ::std::tuple<ElementPointer, Size>& array) {
404 template <
typename T>
410 template <
typename T>
416 template <
typename K,
typename V>
425 template <
typename F,
typename Tuple,
size_t... Idx>
427 -> decltype(std::forward<F>(
f)(
428 std::get<Idx>(std::forward<Tuple>(args))...)) {
429 return std::forward<F>(
f)(std::get<Idx>(std::forward<Tuple>(args))...);
433 template <
typename F,
typename Tuple>
435 std::forward<F>(
f), std::forward<Tuple>(args),
438 return ApplyImpl(std::forward<F>(
f), std::forward<Tuple>(args),
456 template <
typename T>
459 template <
typename R,
typename... Args>
462 static constexpr
size_t ArgumentCount =
sizeof...(Args);
471 template <
typename R,
typename... Args>
472 constexpr
size_t Function<R(Args...)>::ArgumentCount;
478 template <
size_t I,
typename T>
481 bool Base64Unescape(
const std::string& encoded, std::string* decoded);
490 #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #define GMOCK_KIND_OF_(type)
virtual ~FailureReporterInterface()
GTEST_API_ void IllegalDoDefault(const char *file, int line)
auto Apply(F &&f, Tuple &&args) -> decltype(ApplyImpl(std::forward< F >(f), std::forward< Tuple >(args), MakeIndexSequence< std::tuple_size< typename std::remove_reference< Tuple >::type >::value >()))
internal::NativeArray< RawElement > type
static const_reference ConstReference(const RawContainer &container)
const type const_reference
internal::NativeArray< RawElement > type
::std::vector<::std::string > Strings
std::integral_constant< bool,(kFromKind==kBool) ? true :(kFromKind !=kToKind) ? false :(kFromKind==kInteger &&(((sizeof(From)< sizeof(To)) &&!(std::is_signed< From >::value &&!std::is_signed< To >::value))||((sizeof(From)==sizeof(To)) &&(std::is_signed< From >::value==std::is_signed< To >::value)))) ? true :(kFromKind==kFloatingPoint &&(sizeof(From)<=sizeof(To))) ? true :false > LosslessArithmeticConvertibleImpl
std::tuple< Args... > ArgumentTuple
static type Copy(const ::std::tuple< ElementPointer, Size > &array)
static const_reference ConstReference(const Element(&array)[N])
const char kInfoVerbosity[]
bool Base64Unescape(const std::string &encoded, std::string *decoded)
const char kWarningVerbosity[]
GTEST_API_ std::string ConvertIdentifierNameToWords(const char *id_name)
GMOCK_DECLARE_KIND_(bool, kBool)
typename MakeIndexSequenceImpl< N >::type MakeIndexSequence
const type const_reference
void(Args...) MakeResultVoid
GTEST_API_ std::string JoinAsKeyValueTuple(const std::vector< const char *> &names, const Strings &values)
virtual void ReportFailure(FailureType type, const char *file, int line, const std::string &message)=0
std::remove_const< Element >::type RawElement
auto ApplyImpl(F &&f, Tuple &&args, IndexSequence< Idx... >) -> decltype(std::forward< F >(f)(std::get< Idx >(std::forward< Tuple >(args))...))
const type & const_reference
GTEST_API_ bool LogIsVisible(LogSeverity severity)
LosslessArithmeticConvertibleImpl< GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To > LosslessArithmeticConvertible
static type Copy(const RawContainer &container)
static const_reference ConstReference(const ::std::tuple< ElementPointer, Size > &array)
void Assert(bool condition, const char *file, int line, const std::string &msg)
IgnoredValue(Args...) MakeResultIgnoredValue
static type Copy(const Element(&array)[N])
std::tuple< Matcher< Args >... > ArgumentMatcherTuple
GTEST_API_ FailureReporterInterface * GetFailureReporter()
const char kErrorVerbosity[]
const Pointer::element_type * GetRawPointer(const Pointer &p)
std::remove_const< typename std::pointer_traits< ElementPointer >::element_type >::type RawElement
void Expect(bool condition, const char *file, int line, const std::string &msg)
GTEST_API_ WithoutMatchers GetWithoutMatchers()
typename std::tuple_element< I, T >::type TupleElement
GTEST_API_ void Log(LogSeverity severity, const std::string &message, int stack_frames_to_skip)