// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// treated as one word. For example, both "FooBar123" and
// "foo_bar_123" are converted to "foo bar 123".
-string ConvertIdentifierNameToWords(const char* id_name);
+GTEST_API_ 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
// smart pointer, or returns p itself when p is already a raw pointer.
// The following default implementation is for the smart pointer case.
template <typename Pointer>
-inline typename Pointer::element_type* GetRawPointer(const Pointer& p) {
+inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
return p.get();
}
// This overloaded version is for the raw pointer case.
public:
// The type of a failure (either non-fatal or fatal).
enum FailureType {
- NONFATAL, FATAL
+ kNonfatal, kFatal
};
virtual ~FailureReporterInterface() {}
};
// Returns the failure reporter used by Google Mock.
-FailureReporterInterface* GetFailureReporter();
+GTEST_API_ FailureReporterInterface* GetFailureReporter();
// Asserts that condition is true; aborts the process with the given
// message if condition is false. We cannot use LOG(FATAL) or CHECK()
inline void Assert(bool condition, const char* file, int line,
const string& msg) {
if (!condition) {
- GetFailureReporter()->ReportFailure(FailureReporterInterface::FATAL,
+ GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
file, line, msg);
}
}
inline void Expect(bool condition, const char* file, int line,
const string& msg) {
if (!condition) {
- GetFailureReporter()->ReportFailure(FailureReporterInterface::NONFATAL,
+ GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,
file, line, msg);
}
}
// Severity level of a log.
enum LogSeverity {
- INFO = 0,
- WARNING = 1
+ kInfo = 0,
+ kWarning = 1
};
// Valid values for the --gmock_verbose flag.
// Returns true iff a log with the given severity is visible according
// to the --gmock_verbose flag.
-bool LogIsVisible(LogSeverity severity);
+GTEST_API_ bool LogIsVisible(LogSeverity severity);
// Prints the given message to stdout iff 'severity' >= the level
// specified by the --gmock_verbose flag. If stack_frames_to_skip >=
// stack_frames_to_skip is treated as 0, since we don't know which
// function calls will be inlined by the compiler and need to be
// conservative.
-void Log(LogSeverity severity, const string& message, int stack_frames_to_skip);
+GTEST_API_ void Log(LogSeverity severity,
+ const string& message,
+ int stack_frames_to_skip);
// TODO(wan@google.com): group all type utilities together.
template <typename T> struct remove_reference { typedef T type; }; // NOLINT
template <typename T> struct remove_reference<T&> { typedef T type; }; // NOLINT
+// DecayArray<T>::type turns an array type U[N] to const U* and preserves
+// other types. Useful for saving a copy of a function argument.
+template <typename T> struct DecayArray { typedef T type; }; // NOLINT
+template <typename T, size_t N> struct DecayArray<T[N]> {
+ typedef const T* type;
+};
+// Sometimes people use arrays whose size is not available at the use site
+// (e.g. extern const char kNamePrefix[]). This specialization covers that
+// case.
+template <typename T> struct DecayArray<T[]> {
+ typedef const T* type;
+};
+
// Invalid<T>() returns an invalid value of type T. This is useful
// when a value of type T is needed for compilation, but the statement
// will not really be executed (or we don't care if the statement
// crashes).
template <typename T>
inline T Invalid() {
- return *static_cast<typename remove_reference<T>::type*>(NULL);
+ return const_cast<typename remove_reference<T>::type&>(
+ *static_cast<volatile typename remove_reference<T>::type*>(NULL));
}
template <>
inline void Invalid<void>() {}
// StlContainer with a reference type.
template <typename T> class StlContainerView<T&>;
+// A type transform to remove constness from the first part of a pair.
+// Pairs like that are used as the value_type of associative containers,
+// and this transform produces a similar but assignable pair.
+template <typename T>
+struct RemoveConstFromKey {
+ typedef T type;
+};
+
+// Partially specialized to remove constness from std::pair<const K, V>.
+template <typename K, typename V>
+struct RemoveConstFromKey<std::pair<const K, V> > {
+ typedef std::pair<K, V> type;
+};
+
+// Mapping from booleans to types. Similar to boost::bool_<kValue> and
+// std::integral_constant<bool, kValue>.
+template <bool kValue>
+struct BooleanConstant {};
+
} // namespace internal
} // namespace testing