Merge in updates for server failure testing.
[awesomized/libmemcached] / libtest / comparison.hpp
index 5c687fc3a6500b5d153b00802b73ca51934f7cbc..09106d9f62134faf7f04e2a1babc40ce8fe0652f 100644 (file)
@@ -62,7 +62,7 @@ bool _compare(const char *file, int line, const char *func, const T_comparable _
         << got_str
         << "\"";
     }
-#if (defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED)
+#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
     else if (typeid(__expected) == typeid(memcached_return_t))
     {
       libtest::stream::make_cerr(file, line, func) << "Expected \"" 
@@ -107,8 +107,43 @@ bool _compare_hint(const char *file, int line, const char *func, T_comparable __
 {
   if (__expected != __actual)
   {
-    libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\" Additionally: \"" << __hint << "\"";
+    if (typeid(__expected) == typeid(test_return_t))
+    {
+      const char *expected_str= test_strerror(test_return_t(__expected));
+      const char *got_str= test_strerror(test_return_t(__actual));
 
+      libtest::stream::make_cerr(file, line, func) << "Expected \"" 
+        << expected_str
+        << "\" got \"" 
+        << got_str
+        << "\""
+        << " Additionally: \"" << __hint << "\"";
+    }
+#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
+    else if (typeid(__expected) == typeid(memcached_return_t))
+    {
+      libtest::stream::make_cerr(file, line, func) << "Expected \"" 
+        << memcached_strerror(NULL, memcached_return_t(__expected)) 
+        << "\" got \"" 
+        << memcached_strerror(NULL, memcached_return_t(__actual)) << "\""
+        << " Additionally: \"" << __hint << "\"";
+    }
+#endif
+#if defined(HAVE_LIBGEARMAN) && HAVE_LIBGEARMAN
+    else if (typeid(__expected) == typeid(gearman_return_t))
+    {
+      libtest::stream::make_cerr(file, line, func) << "Expected \"" 
+        << gearman_strerror(gearman_return_t(__expected)) 
+        << "\" got \"" 
+        << gearman_strerror(gearman_return_t(__actual)) << "\""
+        << " Additionally: \"" << __hint << "\"";
+    }
+#endif
+    else
+    {
+      libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\""
+        << " Additionally: \"" << __hint << "\"";
+    }
     return false;
   }