Updated to gmock-1.7.0
[alexxy/gromacs.git] / src / external / gmock-1.7.0 / include / gmock / internal / gmock-internal-utils.h
similarity index 91%
rename from src/external/gmock-1.6.0/include/gmock/internal/gmock-internal-utils.h
rename to src/external/gmock-1.7.0/include/gmock/internal/gmock-internal-utils.h
index f0fd868264fb80d19722446aed51ba08732e2696..e12b7d7d9139787d32c58cec07df8cf6e914af05 100644 (file)
@@ -53,7 +53,7 @@ namespace internal {
 // 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
@@ -73,7 +73,7 @@ struct PointeeOf<T*> { typedef T type; };  // NOLINT
 // 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.
@@ -260,7 +260,7 @@ class FailureReporterInterface {
  public:
   // The type of a failure (either non-fatal or fatal).
   enum FailureType {
-    NONFATAL, FATAL
+    kNonfatal, kFatal
   };
 
   virtual ~FailureReporterInterface() {}
@@ -271,7 +271,7 @@ class 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()
@@ -281,7 +281,7 @@ FailureReporterInterface* GetFailureReporter();
 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);
   }
 }
@@ -294,7 +294,7 @@ inline void Assert(bool condition, const char* file, int line) {
 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);
   }
 }
@@ -304,8 +304,8 @@ inline void Expect(bool condition, const char* file, int line) {
 
 // Severity level of a log.
 enum LogSeverity {
-  INFO = 0,
-  WARNING = 1
+  kInfo = 0,
+  kWarning = 1
 };
 
 // Valid values for the --gmock_verbose flag.
@@ -319,7 +319,7 @@ const char kErrorVerbosity[] = "error";
 
 // 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 >=
@@ -328,7 +328,9 @@ bool LogIsVisible(LogSeverity severity);
 // 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.
 
@@ -346,13 +348,27 @@ template <typename T> struct type_equals<T, T> : public true_type {};
 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>() {}
@@ -457,6 +473,25 @@ class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > {
 // 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