39 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
40 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
45 #include <type_traits>
59 # pragma warning(push)
60 # pragma warning(disable:4100)
61 # pragma warning(disable:4805)
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>
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
140 #define GMOCK_DECLARE_KIND_(type, kind) \
141 template <> struct KindOf<type> { enum { value = kind }; }
156 #if GMOCK_WCHAR_T_IS_NATIVE_
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.");
336 int stack_frames_to_skip);
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>
433 static type Copy(
const RawContainer& container) {
return container; }
437 template <
typename Element,
size_t N>
451 testing::StaticAssertTypeEq<Element, RawElement>();
461 template <
typename ElementPo
inter,
typename Size>
470 const ::std::tuple<ElementPointer, Size>&
array) {
481 template <
typename T>
class StlContainerView<
T&>;
486 template <
typename T>
492 template <
typename K,
typename V>
499 template <
bool kValue>
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>
526 -> decltype(
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);
561 template <
typename R,
typename...
Args>
565 # pragma warning(pop)
571 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_