testing
[awesomized/libmemcached] / test / tests / memcached / util.cpp
index 3fb018a3a635708e624daed8fd98b0c55ecdc612..3256fced7d7b01c58d54f05793f0698df90cc3a9 100644 (file)
@@ -1,17 +1,10 @@
 #include "test/lib/common.hpp"
 #include "test/lib/MemcachedCluster.hpp"
+#include "test/fixtures/callbacks.hpp"
 
 #include "libmemcached/instance.hpp"
 #include "libmemcachedutil/common.h"
 
-static memcached_return_t ping_callback(const memcached_st *, const memcached_instance_st *instance, void *) {
-  memcached_return_t rc;
-
-  REQUIRE(libmemcached_util_ping(memcached_server_name(instance), memcached_server_port(instance), &rc));
-  REQUIRE(rc == MEMCACHED_SUCCESS);
-  return MEMCACHED_SUCCESS;
-}
-
 TEST_CASE("memcached_util") {
   SECTION("version_check") {
     auto test = MemcachedCluster::mixed();
@@ -43,6 +36,7 @@ TEST_CASE("memcached_util") {
     }
   }
 
+  // see sasl.cpp for getpid2 test
   SECTION("getpid") {
     auto test = MemcachedCluster::network();
     memcached_return_t rc;
@@ -53,9 +47,10 @@ TEST_CASE("memcached_util") {
     }
 
     REQUIRE(-1 == libmemcached_util_getpid("localhost", 1, &rc));
-    REQUIRE_RC(MEMCACHED_CONNECTION_FAILURE, rc);
+    REQUIRE(memcached_fatal(rc));
   }
 
+  // see sasl.cpp for ping2 test
   SECTION("ping") {
     auto test = MemcachedCluster::network();
     auto memc = &test.memc;
@@ -149,6 +144,21 @@ TEST_CASE("memcached_util") {
           REQUIRE_SUCCESS(rc);
           REQUIRE(h);
           REQUIRE(9999 == memcached_behavior_get(h, MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK));
+          REQUIRE_FALSE(9999 == memcached_behavior_get(h, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK));
+          REQUIRE_SUCCESS(memcached_pool_release(pool, h));
+        }
+
+        REQUIRE_SUCCESS(memcached_pool_behavior_get(pool, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, &val));
+        REQUIRE_FALSE(val == 9999);
+        REQUIRE_SUCCESS(memcached_pool_behavior_set(pool, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, 9999));
+        REQUIRE_SUCCESS(memcached_pool_behavior_get(pool, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, &val));
+        REQUIRE(val == 9999);
+
+        for (auto &h : hold) {
+          h = memcached_pool_fetch(pool, nullptr, &rc);
+          REQUIRE_SUCCESS(rc);
+          REQUIRE(h);
+          REQUIRE(9999 == memcached_behavior_get(h, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK));
         }
       }