39#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
40#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
46#include "gmock/internal/gmock-port.h"
47#include "gtest/gtest.h"
60# pragma warning(disable:4100)
61# pragma warning(disable:4805)
66GTEST_API_ std::string JoinAsTuple(
const Strings& fields);
72GTEST_API_ std::string ConvertIdentifierNameToWords(
const char* id_name);
77template <
typename Po
inter>
78inline const typename Pointer::element_type* GetRawPointer(
const Pointer& p) {
82template <
typename Element>
83inline Element* GetRawPointer(Element* p) {
return p; }
89#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
92# define GMOCK_WCHAR_T_IS_NATIVE_ 1
101 kBool, kInteger, kFloatingPoint, kOther
106 enum { value = kOther };
110#define GMOCK_DECLARE_KIND_(type, kind) \
111 template <> struct KindOf<type> { enum { value = kind }; }
113GMOCK_DECLARE_KIND_(
bool, kBool);
116GMOCK_DECLARE_KIND_(
char, kInteger);
117GMOCK_DECLARE_KIND_(
signed char, kInteger);
118GMOCK_DECLARE_KIND_(
unsigned char, kInteger);
119GMOCK_DECLARE_KIND_(
short, kInteger);
120GMOCK_DECLARE_KIND_(
unsigned short, kInteger);
121GMOCK_DECLARE_KIND_(
int, kInteger);
122GMOCK_DECLARE_KIND_(
unsigned int, kInteger);
123GMOCK_DECLARE_KIND_(
long, kInteger);
124GMOCK_DECLARE_KIND_(
unsigned long, kInteger);
125GMOCK_DECLARE_KIND_(
long long, kInteger);
126GMOCK_DECLARE_KIND_(
unsigned long long, kInteger);
128#if GMOCK_WCHAR_T_IS_NATIVE_
129GMOCK_DECLARE_KIND_(
wchar_t, kInteger);
133GMOCK_DECLARE_KIND_(
float, kFloatingPoint);
134GMOCK_DECLARE_KIND_(
double, kFloatingPoint);
135GMOCK_DECLARE_KIND_(
long double, kFloatingPoint);
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>
154using LosslessArithmeticConvertibleImpl = std::integral_constant<
158 (kFromKind == kBool) ?
true
161 : (kFromKind != kToKind) ? false
162 : (kFromKind == kInteger &&
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
186template <
typename From,
typename To>
187using LosslessArithmeticConvertible =
188 LosslessArithmeticConvertibleImpl<GMOCK_KIND_OF_(From), From,
189 GMOCK_KIND_OF_(
To),
To>;
203 virtual void ReportFailure(FailureType type,
const char* file,
int line,
204 const std::string& message) = 0;
215inline void Assert(
bool condition,
const char* file,
int line,
216 const std::string& msg) {
218 GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
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) {
231 GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,
235inline void Expect(
bool condition,
const char* file,
int line) {
236 Expect(condition, file, line,
"Expectation failed.");
248const char kInfoVerbosity[] =
"info";
250const char kWarningVerbosity[] =
"warning";
252const char kErrorVerbosity[] =
"error";
256GTEST_API_
bool LogIsVisible(LogSeverity severity);
265GTEST_API_
void Log(LogSeverity severity,
const std::string& message,
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>
327 typedef RawContainer type;
328 typedef const type& const_reference;
330 static const_reference ConstReference(
const RawContainer& container) {
331 static_assert(!std::is_const<RawContainer>::value,
332 "RawContainer type must not be const");
335 static type Copy(
const RawContainer& container) {
return container; }
339template <
typename Element,
size_t 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");
356 static type Copy(
const Element (&array)[N]) {
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) {
395template <
typename K,
typename V>
397 typedef std::pair<K, V> type;
402GTEST_API_
void IllegalDoDefault(
const char* file,
int line);
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),
414 MakeIndexSequence<std::tuple_size<
415 typename std::remove_reference<Tuple>::type>::value>())) {
416 return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
417 MakeIndexSequence<std::tuple_size<
418 typename std::remove_reference<Tuple>::type>::value>());
437template <
typename R,
typename... Args>
440 static constexpr size_t ArgumentCount =
sizeof...(Args);
443 using ArgumentTuple = std::tuple<Args...>;
444 using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>;
445 using MakeResultVoid = void(Args...);
449template <
typename R,
typename... Args>
450constexpr size_t Function<R(Args...)>::ArgumentCount;
Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.
Definition pointer.h:79
Definition gmock-internal-utils.h:52
Definition gmock-internal-utils.h:193
Definition gtest-internal.h:122
Definition gtest-internal.h:1094
Definition gmock-internal-utils.h:325
Definition googletest-port-test.cc:192
Definition gmock-internal-utils.h:274
Definition gtest-internal.h:1208
Definition gmock-internal-utils.h:435
Definition gtest-internal.h:1158
Definition gmock-internal-utils.h:105
Definition gtest-internal.h:1083
Definition gtest-internal.h:1082
Definition gmock-internal-utils.h:390