"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googlemock/include/gmock/internal/gmock-internal-utils.h" between
googletest-release-1.10.0.tar.gz and googletest-release-1.11.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

gmock-internal-utils.h  (googletest-release-1.10.0):gmock-internal-utils.h  (googletest-release-1.11.0)
skipping to change at line 38 skipping to change at line 38
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file defines some utilities useful for implementing Google // This file defines some utilities useful for implementing Google
// Mock. They are subject to change without notice, so please DO NOT // Mock. They are subject to change without notice, so please DO NOT
// USE THEM IN USER CODE. // USE THEM IN USER CODE.
// GOOGLETEST_CM0002 DO NOT DELETE // GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
#include <stdio.h> #include <stdio.h>
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace testing { namespace testing {
skipping to change at line 73 skipping to change at line 73
// Joins a vector of strings as if they are fields of a tuple; returns // Joins a vector of strings as if they are fields of a tuple; returns
// the joined string. // the joined string.
GTEST_API_ std::string JoinAsTuple(const Strings& fields); GTEST_API_ std::string JoinAsTuple(const Strings& fields);
// Converts an identifier name to a space-separated list of lower-case // Converts an identifier name to a space-separated list of lower-case
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is // words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// treated as one word. For example, both "FooBar123" and // treated as one word. For example, both "FooBar123" and
// "foo_bar_123" are converted to "foo bar 123". // "foo_bar_123" are converted to "foo bar 123".
GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name); GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name);
// PointeeOf<Pointer>::type is the type of a value pointed to by a
// Pointer, which can be either a smart pointer or a raw pointer. The
// following default implementation is for the case where Pointer is a
// smart pointer.
template <typename Pointer>
struct PointeeOf {
// Smart pointer classes define type element_type as the type of
// their pointees.
typedef typename Pointer::element_type type;
};
// This specialization is for the raw pointer case.
template <typename T>
struct PointeeOf<T*> { typedef T type; }; // NOLINT
// GetRawPointer(p) returns the raw pointer underlying p when p is a // GetRawPointer(p) returns the raw pointer underlying p when p is a
// smart pointer, or returns p itself when p is already a raw pointer. // smart pointer, or returns p itself when p is already a raw pointer.
// The following default implementation is for the smart pointer case. // The following default implementation is for the smart pointer case.
template <typename Pointer> template <typename Pointer>
inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) { inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
return p.get(); return p.get();
} }
// This overloaded version is for the raw pointer case. // This overloaded version is for the raw pointer case.
template <typename Element> template <typename Element>
inline Element* GetRawPointer(Element* p) { return p; } inline Element* GetRawPointer(Element* p) { return p; }
skipping to change at line 138 skipping to change at line 124
// All standard integer types. // All standard integer types.
GMOCK_DECLARE_KIND_(char, kInteger); GMOCK_DECLARE_KIND_(char, kInteger);
GMOCK_DECLARE_KIND_(signed char, kInteger); GMOCK_DECLARE_KIND_(signed char, kInteger);
GMOCK_DECLARE_KIND_(unsigned char, kInteger); GMOCK_DECLARE_KIND_(unsigned char, kInteger);
GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(int, kInteger); GMOCK_DECLARE_KIND_(int, kInteger);
GMOCK_DECLARE_KIND_(unsigned int, kInteger); GMOCK_DECLARE_KIND_(unsigned int, kInteger);
GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(long long, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned long long, kInteger); // NOLINT
#if GMOCK_WCHAR_T_IS_NATIVE_ #if GMOCK_WCHAR_T_IS_NATIVE_
GMOCK_DECLARE_KIND_(wchar_t, kInteger); GMOCK_DECLARE_KIND_(wchar_t, kInteger);
#endif #endif
// Non-standard integer types.
GMOCK_DECLARE_KIND_(Int64, kInteger);
GMOCK_DECLARE_KIND_(UInt64, kInteger);
// All standard floating-point types. // All standard floating-point types.
GMOCK_DECLARE_KIND_(float, kFloatingPoint); GMOCK_DECLARE_KIND_(float, kFloatingPoint);
GMOCK_DECLARE_KIND_(double, kFloatingPoint); GMOCK_DECLARE_KIND_(double, kFloatingPoint);
GMOCK_DECLARE_KIND_(long double, kFloatingPoint); GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
#undef GMOCK_DECLARE_KIND_ #undef GMOCK_DECLARE_KIND_
// Evaluates to the kind of 'type'. // Evaluates to the kind of 'type'.
#define GMOCK_KIND_OF_(type) \ #define GMOCK_KIND_OF_(type) \
static_cast< ::testing::internal::TypeKind>( \ static_cast< ::testing::internal::TypeKind>( \
::testing::internal::KindOf<type>::value) ::testing::internal::KindOf<type>::value)
// Evaluates to true if and only if integer type T is signed.
#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value // LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value
// is true if and only if arithmetic type From can be losslessly converted to // is true if and only if arithmetic type From can be losslessly converted to
// arithmetic type To. // arithmetic type To.
// //
// It's the user's responsibility to ensure that both From and To are // It's the user's responsibility to ensure that both From and To are
// raw (i.e. has no CV modifier, is not a pointer, and is not a // raw (i.e. has no CV modifier, is not a pointer, and is not a
// reference) built-in arithmetic types, kFromKind is the kind of // reference) built-in arithmetic types, kFromKind is the kind of
// From, and kToKind is the kind of To; the value is // From, and kToKind is the kind of To; the value is
// implementation-defined when the above pre-condition is violated. // implementation-defined when the above pre-condition is violated.
template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To> template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>
struct LosslessArithmeticConvertibleImpl : public std::false_type {}; using LosslessArithmeticConvertibleImpl = std::integral_constant<
bool,
// Converting bool to bool is lossless. // clang-format off
template <> // Converting from bool is always lossless
struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool> (kFromKind == kBool) ? true
: public std::true_type {}; // Converting between any other type kinds will be lossy if the type
// kinds are not the same.
// Converting bool to any integer type is lossless. : (kFromKind != kToKind) ? false
template <typename To> : (kFromKind == kInteger &&
struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To> // Converting between integers of different widths is allowed so long
: public std::true_type {}; // as the conversion does not go from signed to unsigned.
(((sizeof(From) < sizeof(To)) &&
// Converting bool to any floating-point type is lossless. !(std::is_signed<From>::value && !std::is_signed<To>::value)) ||
template <typename To> // Converting between integers of the same width only requires the
struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To> // two types to have the same signedness.
: public std::true_type {}; ((sizeof(From) == sizeof(To)) &&
(std::is_signed<From>::value == std::is_signed<To>::value)))
// Converting an integer to bool is lossy. ) ? true
template <typename From> // Floating point conversions are lossless if and only if `To` is at least
struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool> // as wide as `From`.
: public std::false_type {}; : (kFromKind == kFloatingPoint && (sizeof(From) <= sizeof(To))) ? true
: false
// Converting an integer to another non-bool integer is lossless // clang-format on
// if and only if the target type's range encloses the source type's range. >;
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
: public bool_constant<
// When converting from a smaller size to a larger size, we are
// fine as long as we are not converting from signed to unsigned.
((sizeof(From) < sizeof(To)) &&
(!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
// When converting between the same size, the signedness must match.
((sizeof(From) == sizeof(To)) &&
(GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT
#undef GMOCK_IS_SIGNED_
// Converting an integer to a floating-point type may be lossy, since
// the format of a floating-point number is implementation-defined.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
: public std::false_type {};
// Converting a floating-point to bool is lossy.
template <typename From>
struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
: public std::false_type {};
// Converting a floating-point to an integer is lossy.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
: public std::false_type {};
// Converting a floating-point to another floating-point is lossless
// if and only if the target type is at least as big as the source type.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<
kFloatingPoint, From, kFloatingPoint, To>
: public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
// LosslessArithmeticConvertible<From, To>::value is true if and only if // LosslessArithmeticConvertible<From, To>::value is true if and only if
// arithmetic type From can be losslessly converted to arithmetic type To. // arithmetic type From can be losslessly converted to arithmetic type To.
// //
// It's the user's responsibility to ensure that both From and To are // It's the user's responsibility to ensure that both From and To are
// raw (i.e. has no CV modifier, is not a pointer, and is not a // raw (i.e. has no CV modifier, is not a pointer, and is not a
// reference) built-in arithmetic types; the value is // reference) built-in arithmetic types; the value is
// implementation-defined when the above pre-condition is violated. // implementation-defined when the above pre-condition is violated.
template <typename From, typename To> template <typename From, typename To>
struct LosslessArithmeticConvertible using LosslessArithmeticConvertible =
: public LosslessArithmeticConvertibleImpl< LosslessArithmeticConvertibleImpl<GMOCK_KIND_OF_(From), From,
GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {}; // NOLINT GMOCK_KIND_OF_(To), To>;
// This interface knows how to report a Google Mock failure (either // This interface knows how to report a Google Mock failure (either
// non-fatal or fatal). // non-fatal or fatal).
class FailureReporterInterface { class FailureReporterInterface {
public: public:
// The type of a failure (either non-fatal or fatal). // The type of a failure (either non-fatal or fatal).
enum FailureType { enum FailureType {
kNonfatal, kFatal kNonfatal, kFatal
}; };
skipping to change at line 336 skipping to change at line 282
// //
class WithoutMatchers { class WithoutMatchers {
private: private:
WithoutMatchers() {} WithoutMatchers() {}
friend GTEST_API_ WithoutMatchers GetWithoutMatchers(); friend GTEST_API_ WithoutMatchers GetWithoutMatchers();
}; };
// Internal use only: access the singleton instance of WithoutMatchers. // Internal use only: access the singleton instance of WithoutMatchers.
GTEST_API_ WithoutMatchers GetWithoutMatchers(); GTEST_API_ WithoutMatchers GetWithoutMatchers();
// Type traits.
// Disable MSVC warnings for infinite recursion, since in this case the // Disable MSVC warnings for infinite recursion, since in this case the
// the recursion is unreachable. // the recursion is unreachable.
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) # pragma warning(push)
# pragma warning(disable:4717) # pragma warning(disable:4717)
#endif #endif
// Invalid<T>() is usable as an expression of type T, but will terminate // Invalid<T>() is usable as an expression of type T, but will terminate
// the program with an assertion failure if actually run. This is useful // the program with an assertion failure if actually run. This is useful
// when a value of type T is needed for compilation, but the statement // when a value of type T is needed for compilation, but the statement
skipping to change at line 422 skipping to change at line 366
return type(array, N, RelationToSourceCopy()); return type(array, N, RelationToSourceCopy());
} }
}; };
// This specialization is used when RawContainer is a native array // This specialization is used when RawContainer is a native array
// represented as a (pointer, size) tuple. // represented as a (pointer, size) tuple.
template <typename ElementPointer, typename Size> template <typename ElementPointer, typename Size>
class StlContainerView< ::std::tuple<ElementPointer, Size> > { class StlContainerView< ::std::tuple<ElementPointer, Size> > {
public: public:
typedef typename std::remove_const< typedef typename std::remove_const<
typename internal::PointeeOf<ElementPointer>::type>::type RawElement; typename std::pointer_traits<ElementPointer>::element_type>::type
RawElement;
typedef internal::NativeArray<RawElement> type; typedef internal::NativeArray<RawElement> type;
typedef const type const_reference; typedef const type const_reference;
static const_reference ConstReference( static const_reference ConstReference(
const ::std::tuple<ElementPointer, Size>& array) { const ::std::tuple<ElementPointer, Size>& array) {
return type(std::get<0>(array), std::get<1>(array), return type(std::get<0>(array), std::get<1>(array),
RelationToSourceReference()); RelationToSourceReference());
} }
static type Copy(const ::std::tuple<ElementPointer, Size>& array) { static type Copy(const ::std::tuple<ElementPointer, Size>& array) {
return type(std::get<0>(array), std::get<1>(array), RelationToSourceCopy()); return type(std::get<0>(array), std::get<1>(array), RelationToSourceCopy());
skipping to change at line 466 skipping to change at line 411
GTEST_API_ void IllegalDoDefault(const char* file, int line); GTEST_API_ void IllegalDoDefault(const char* file, int line);
template <typename F, typename Tuple, size_t... Idx> template <typename F, typename Tuple, size_t... Idx>
auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>) -> decltype( auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>) -> decltype(
std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) { std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) {
return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...); return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...);
} }
// Apply the function to a tuple of arguments. // Apply the function to a tuple of arguments.
template <typename F, typename Tuple> template <typename F, typename Tuple>
auto Apply(F&& f, Tuple&& args) auto Apply(F&& f, Tuple&& args) -> decltype(
-> decltype(ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
MakeIndexSequence<std::tuple_size<Tuple>::value>())) { MakeIndexSequence<std::tuple_size<
typename std::remove_reference<Tuple>::type>::value>())) {
return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
MakeIndexSequence<std::tuple_size<Tuple>::value>()); MakeIndexSequence<std::tuple_size<
typename std::remove_reference<Tuple>::type>::value>());
} }
// Template struct Function<F>, where F must be a function type, contains // Template struct Function<F>, where F must be a function type, contains
// the following typedefs: // the following typedefs:
// //
// Result: the function's return type. // Result: the function's return type.
// Arg<N>: the type of the N-th argument, where N starts with 0. // Arg<N>: the type of the N-th argument, where N starts with 0.
// ArgumentTuple: the tuple type consisting of all parameters of F. // ArgumentTuple: the tuple type consisting of all parameters of F.
// ArgumentMatcherTuple: the tuple type consisting of Matchers for all // ArgumentMatcherTuple: the tuple type consisting of Matchers for all
// parameters of F. // parameters of F.
skipping to change at line 494 skipping to change at line 441
// the function type obtained by substituting Something // the function type obtained by substituting Something
// for the return type of F. // for the return type of F.
template <typename T> template <typename T>
struct Function; struct Function;
template <typename R, typename... Args> template <typename R, typename... Args>
struct Function<R(Args...)> { struct Function<R(Args...)> {
using Result = R; using Result = R;
static constexpr size_t ArgumentCount = sizeof...(Args); static constexpr size_t ArgumentCount = sizeof...(Args);
template <size_t I> template <size_t I>
using Arg = ElemFromList<I, typename MakeIndexSequence<sizeof...(Args)>::type, using Arg = ElemFromList<I, Args...>;
Args...>;
using ArgumentTuple = std::tuple<Args...>; using ArgumentTuple = std::tuple<Args...>;
using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>; using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>;
using MakeResultVoid = void(Args...); using MakeResultVoid = void(Args...);
using MakeResultIgnoredValue = IgnoredValue(Args...); using MakeResultIgnoredValue = IgnoredValue(Args...);
}; };
template <typename R, typename... Args> template <typename R, typename... Args>
constexpr size_t Function<R(Args...)>::ArgumentCount; constexpr size_t Function<R(Args...)>::ArgumentCount;
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) # pragma warning(pop)
#endif #endif
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
 End of changes. 13 change blocks. 
94 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)