libmemcached: add MEMCACHED_BEHAVIOR_META_PROTOCOL
[m6w6/libmemcached] / test / tests / memcached / simple.cpp
index 6856d63e3d5452b5f137551aacc02b1257d9e3d4..bf7a64eec5a5e7229f1cdcb660e4e398eedfe06a 100644 (file)
@@ -17,19 +17,25 @@ TEST_CASE("memcached_simple") {
     }
 
     uint64_t buffered = GENERATE(0, 1);
-    uint64_t binary = GENERATE(0, 1);
+    auto proto = GENERATE(as<memcached_behavior_t>{}, 0, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, MEMCACHED_BEHAVIOR_META_PROTOCOL);
 
     REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, buffered));
-    REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, binary));
+    if (proto) {
+      REQUIRE_SUCCESS(memcached_behavior_set(memc, proto, 1));
+    }
+
+    if (proto == MEMCACHED_BEHAVIOR_META_PROTOCOL && !test.isGEVersion(1, 6)) {
+      continue;
+    }
 
-    DYNAMIC_SECTION("set (buffered=" << buffered << ",binary=" << binary << ")") {
+    DYNAMIC_SECTION("set (buffered=" << buffered << ",proto=" << proto << ")") {
       for (auto i = 0; i < 10; ++i) {
         REQUIRE_RC(buffered ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS,
             memcached_set(memc, S(__func__), S(__func__), 0, 0));
       }
     }
 
-    DYNAMIC_SECTION("add (buffered=" << buffered << ",binary=" << binary << ")") {
+    DYNAMIC_SECTION("add (buffered=" << buffered << " " << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ")") {
       memcached_return_t rc;
 
       Malloced empty(memcached_get(memc, S(__func__), nullptr, nullptr, &rc));
@@ -49,18 +55,18 @@ TEST_CASE("memcached_simple") {
       REQUIRE(*val);
       REQUIRE(string(__func__) == string(*val, len));
 
-      REQUIRE_RC(binary ? MEMCACHED_DATA_EXISTS : MEMCACHED_NOTSTORED,
+      REQUIRE_RC(proto == MEMCACHED_BEHAVIOR_BINARY_PROTOCOL ? MEMCACHED_DATA_EXISTS : MEMCACHED_NOTSTORED,
           memcached_add(memc, S(__func__), S("update"), 0, 0));
     }
 
-    DYNAMIC_SECTION("replace (buffered=" << buffered << ",binary=" << binary << ")") {
+    DYNAMIC_SECTION("replace (buffered=" << buffered << " " << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ")") {
       REQUIRE_RC(buffered ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS,
           memcached_set(memc, S(__func__), S(__func__), 0, 0));
 
       REQUIRE_SUCCESS(memcached_replace(memc, S(__func__), S("replaced"), 0, 0));
     }
 
-    DYNAMIC_SECTION("not found (buffered=" << buffered << ",binary=" << binary << ")") {
+    DYNAMIC_SECTION("not found (buffered=" << buffered << " " << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ")") {
       memcached_return_t rc;
       Malloced val(memcached_get(memc, S("not-found"), nullptr, nullptr, &rc));
       REQUIRE_RC(MEMCACHED_NOTFOUND, rc);
@@ -71,11 +77,11 @@ TEST_CASE("memcached_simple") {
       REQUIRE_FALSE(*val);
     }
 
-    DYNAMIC_SECTION("verbosity (buffered=" << buffered << ",binary=" << binary << ")") {
+    DYNAMIC_SECTION("verbosity (buffered=" << buffered << " " << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ")") {
       REQUIRE_SUCCESS(memcached_verbosity(memc, 0));
     }
 
-    DYNAMIC_SECTION("version (buffered=" << buffered << ",binary=" << binary << ")") {
+    DYNAMIC_SECTION("version (buffered=" << buffered << " " << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ")") {
       REQUIRE_SUCCESS(memcached_version(memc));
     }
   }