39 #ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
40 #define GOOGLETEST_GOOGLEMOCK_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)
77 template <
typename Po
inter>
78 inline const typename Pointer::element_type*
GetRawPointer(
const Pointer& p) {
82 template <
typename Element>
89 #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
92 # define GMOCK_WCHAR_T_IS_NATIVE_ 1
105 template <
typename T>
struct KindOf {
110 #define GMOCK_DECLARE_KIND_(type, kind) \
111 template <> struct KindOf<type> { enum { value = kind }; }
128 #if GMOCK_WCHAR_T_IS_NATIVE_
137 #undef GMOCK_DECLARE_KIND_
140 #define GMOCK_KIND_OF_(type) \
141 static_cast< ::testing::internal::TypeKind>( \
142 ::testing::internal::KindOf<type>::value)
153 template <TypeKind kFromKind,
typename From, TypeKind kToKind,
typename To>
158 (kFromKind ==
kBool) ?
true
161 : (kFromKind != kToKind) ? false
165 (((
sizeof(From) <
sizeof(To)) &&
166 !(std::is_signed<From>::value && !std::is_signed<To>::value)) ||
169 ((
sizeof(From) ==
sizeof(To)) &&
170 (std::is_signed<From>::value == std::is_signed<To>::value)))
174 : (kFromKind ==
kFloatingPoint && (
sizeof(From) <=
sizeof(To))) ? true
186 template <
typename From,
typename To>
193 class FailureReporterInterface {
204 const std::string& message) = 0;
215 inline void Assert(
bool condition,
const char* file,
int line,
216 const std::string& msg) {
222 inline void Assert(
bool condition,
const char* file,
int line) {
223 Assert(condition, file, line,
"Assertion failed.");
228 inline void Expect(
bool condition,
const char* file,
int line,
229 const std::string& msg) {
235 inline void Expect(
bool condition,
const char* file,
int line) {
236 Expect(condition, file, line,
"Expectation failed.");
266 int stack_frames_to_skip);
274 class WithoutMatchers {
286 # pragma warning(push)
287 # pragma warning(disable:4717)
295 template <
typename T>
297 Assert(
false,
"", -1,
"Internal error: attempt to return invalid value");
305 # pragma warning(pop)
324 template <
class RawContainer>
325 class StlContainerView {
331 static_assert(!std::is_const<RawContainer>::value,
332 "RawContainer type must not be const");
335 static type Copy(
const RawContainer& container) {
return container; }
339 template <
typename Element,
size_t N>
340 class StlContainerView<Element[N]> {
342 typedef typename std::remove_const<Element>::type
RawElement;
352 static_assert(std::is_same<Element, RawElement>::value,
353 "Element type must not be const");
363 template <
typename ElementPo
inter,
typename Size>
364 class StlContainerView< ::std::tuple<ElementPointer, Size> > {
366 typedef typename std::remove_const<
367 typename std::pointer_traits<ElementPointer>::element_type>
::type
373 const ::std::tuple<ElementPointer, Size>& array) {
374 return type(std::get<0>(array), std::get<1>(array),
377 static type Copy(const ::std::tuple<ElementPointer, Size>& array) {
384 template <
typename T>
class StlContainerView<T&>;
389 template <
typename T>
390 struct RemoveConstFromKey {
395 template <
typename K,
typename V>
404 template <
typename F,
typename Tuple,
size_t... Idx>
406 std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) {
407 return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...);
411 template <
typename F,
typename Tuple>
412 auto Apply(F&& f, Tuple&& args) -> decltype(
413 ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
415 typename std::remove_reference<Tuple>::type>::value>())) {
416 return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
418 typename std::remove_reference<Tuple>::type>::value>());
434 template <
typename T>
437 template <
typename R,
typename... Args>
438 struct Function<R(Args...)> {
440 static constexpr
size_t ArgumentCount =
sizeof...(Args);
449 template <
typename R,
typename... Args>
450 constexpr
size_t Function<R(Args...)>::ArgumentCount;
453 # pragma warning(pop)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:193
virtual void ReportFailure(FailureType type, const char *file, int line, const std::string &message)=0
virtual ~FailureReporterInterface()
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:200
FailureType
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:196
@ kFatal
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:197
@ kNonfatal
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:197
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:122
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1094
const type const_reference
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:370
internal::NativeArray< RawElement > type
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:369
std::remove_const< typename std::pointer_traits< ElementPointer >::element_type >::type RawElement
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:368
static type Copy(const ::std::tuple< ElementPointer, Size > &array)
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:377
static const_reference ConstReference(const ::std::tuple< ElementPointer, Size > &array)
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:372
internal::NativeArray< RawElement > type
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:343
const type const_reference
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:349
std::remove_const< Element >::type RawElement
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:342
static const_reference ConstReference(const Element(&array)[N])
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:351
static type Copy(const Element(&array)[N])
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:356
RawContainer type
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:327
static const_reference ConstReference(const RawContainer &container)
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:330
static type Copy(const RawContainer &container)
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:335
const type & const_reference
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:328
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:274
friend GTEST_API_ WithoutMatchers GetWithoutMatchers()
#define GTEST_API_
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:775
#define GMOCK_KIND_OF_(type)
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:140
GTEST_API_ std::string ConvertIdentifierNameToWords(const char *id_name)
LogSeverity
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:240
@ kWarning
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:242
@ kInfo
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:241
GMOCK_DECLARE_KIND_(bool, kBool)
T Invalid()
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:296
::std::vector< ::std::string > Strings
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest-printers.h:909
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 >()))
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:412
const char kInfoVerbosity[]
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:248
GTEST_API_ std::string JoinAsTuple(const Strings &fields)
GTEST_API_ bool LogIsVisible(LogSeverity severity)
auto ApplyImpl(F &&f, Tuple &&args, IndexSequence< Idx... >) -> decltype(std::forward< F >(f)(std::get< Idx >(std::forward< Tuple >(args))...))
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:405
GTEST_API_ void Log(LogSeverity severity, const std::string &message, int stack_frames_to_skip)
GTEST_API_ FailureReporterInterface * GetFailureReporter()
void Assert(bool condition, const char *file, int line, const std::string &msg)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:215
const char kWarningVerbosity[]
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:250
GTEST_API_ void IllegalDoDefault(const char *file, int line)
TypeKind
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:100
@ kInteger
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:101
@ kOther
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:101
@ kFloatingPoint
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:101
@ kBool
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:101
LosslessArithmeticConvertibleImpl< GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To > LosslessArithmeticConvertible
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:189
typename MakeIndexSequenceImpl< N >::type MakeIndexSequence
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1185
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
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:177
GTEST_API_ WithoutMatchers GetWithoutMatchers()
const Pointer::element_type * GetRawPointer(const Pointer &p)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:78
void Expect(bool condition, const char *file, int line, const std::string &msg)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:228
const char kErrorVerbosity[]
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:252
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:154
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1208
IgnoredValue(Args...) MakeResultIgnoredValue
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:446
R Result
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:439
void(Args...) MakeResultVoid
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:445
std::tuple< Matcher< Args >... > ArgumentMatcherTuple
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:444
std::tuple< Args... > ArgumentTuple
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:443
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:435
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1158
@ value
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:106
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1083
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1082
std::pair< K, V > type
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:397
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:390
T type
Definition: cmake-build-release/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:391