39#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
40#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
60# pragma warning(disable:4100)
61# pragma warning(disable:4805)
77template <
typename Po
inter>
78inline const typename Pointer::element_type*
GetRawPointer(
const Pointer&
p) {
82template <
typename Element>
89#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
92# define GMOCK_WCHAR_T_IS_NATIVE_ 1
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)
153template <TypeKind kFromKind,
typename From, TypeKind kToKind,
typename To>
158 (kFromKind ==
kBool) ?
true
161 : (kFromKind != kToKind) ? false
165 (((
sizeof(From) <
sizeof(
To)) &&
169 ((
sizeof(From) ==
sizeof(
To)) &&
186template <
typename From,
typename To>
204 const std::string&
message) = 0;
215inline void Assert(
bool condition,
const char*
file,
int line,
216 const std::string& msg) {
222inline void Assert(
bool condition,
const char*
file,
int line) {
223 Assert(condition,
file, line,
"Assertion failed.");
228inline void Expect(
bool condition,
const char*
file,
int line,
229 const std::string& msg) {
235inline void Expect(
bool condition,
const char*
file,
int line) {
236 Expect(condition,
file, line,
"Expectation failed.");
266 int stack_frames_to_skip);
286# pragma warning(push)
287# pragma warning(disable:4717)
297 Assert(
false,
"", -1,
"Internal error: attempt to return invalid value");
324template <
class RawContainer>
332 "RawContainer type must not be const");
335 static type Copy(
const RawContainer& container) {
return container; }
339template <
typename Element,
size_t N>
353 "Element type must not be const");
363template <
typename ElementPo
inter,
typename 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) {
384template <
typename T>
class StlContainerView<T&>;
395template <
typename K,
typename V>
404template <
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))...);
411template <
typename F,
typename Tuple>
412auto Apply(F&& f, Tuple&& args) ->
decltype(
413 ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
416 return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
437template <
typename R,
typename... Args>
440 static constexpr size_t ArgumentCount =
sizeof...(Args);
449template <
typename R,
typename... Args>
450constexpr size_t Function<R(Args...)>::ArgumentCount;
#define GMOCK_KIND_OF_(type)
GTEST_API_ std::string ConvertIdentifierNameToWords(const char *id_name)
GMOCK_DECLARE_KIND_(bool, kBool)
const char kErrorVerbosity[]
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 >()))
GTEST_API_ std::string JoinAsTuple(const Strings &fields)
::std::vector< ::std::string > Strings
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))...))
GTEST_API_ void Log(LogSeverity severity, const std::string &message, int stack_frames_to_skip)
GTEST_API_ FailureReporterInterface * GetFailureReporter()
const char kInfoVerbosity[]
void Assert(bool condition, const char *file, int line, const std::string &msg)
GTEST_API_ void IllegalDoDefault(const char *file, int line)
LosslessArithmeticConvertibleImpl< GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To > LosslessArithmeticConvertible
typename MakeIndexSequenceImpl< N >::type MakeIndexSequence
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
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)
const char kWarningVerbosity[]
virtual void ReportFailure(FailureType type, const char *file, int line, const std::string &message)=0
virtual ~FailureReporterInterface()
friend GTEST_API_ WithoutMatchers GetWithoutMatchers()
static const_reference ConstReference(const RawContainer &container)
static type Copy(const RawContainer &container)
const type & const_reference
internal::NativeArray< RawElement > type
const type const_reference
std::remove_const< Element >::type RawElement
static const_reference ConstReference(const Element(&array)[N])
static type Copy(const Element(&array)[N])
const type const_reference
std::remove_const< typenamestd::pointer_traits< ElementPointer >::element_type >::type RawElement
internal::NativeArray< RawElement > type
static type Copy(const ::std::tuple< ElementPointer, Size > &array)
static const_reference ConstReference(const ::std::tuple< ElementPointer, Size > &array)
IgnoredValue(Args...) MakeResultIgnoredValue
void(Args...) MakeResultVoid
std::tuple< Matcher< Args >... > ArgumentMatcherTuple
std::tuple< Args... > ArgumentTuple