X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=test%2Ftests%2Fmemcached%2Finc_dec.cpp;h=403394793f5bef26a9ca0ab3f391373e248ef72b;hb=5a6a6ab8eb7b4ad34b335e812fae6dbccc489f48;hp=00f7435e18d0dcefe6ef1ca991e996de72bfef13;hpb=bcc1a6ecf1eadcf69dd9efa02fee69ee63949ca0;p=awesomized%2Flibmemcached diff --git a/test/tests/memcached/inc_dec.cpp b/test/tests/memcached/inc_dec.cpp index 00f7435e..40339479 100644 --- a/test/tests/memcached/inc_dec.cpp +++ b/test/tests/memcached/inc_dec.cpp @@ -8,26 +8,32 @@ TEST_CASE("memcached_inc_dec") { LOOPED_SECTION(tests) { auto memc = &test.memc; - uint64_t binary = GENERATE(0, 1); + auto proto = GENERATE(as{}, 0, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, MEMCACHED_BEHAVIOR_META_PROTOCOL); char *prefix = GENERATE(as{}, "", "namespace:"); - REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, binary)); + if (proto == MEMCACHED_BEHAVIOR_META_PROTOCOL && !test.isGEVersion(1, 6)) { + continue; + } + if (proto) { + REQUIRE_SUCCESS(memcached_behavior_set(memc, proto, 1)); + } if (*prefix) { REQUIRE_SUCCESS(memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, prefix)); } - DYNAMIC_SECTION("increment (binary=" << binary << ", prefix=" << prefix << ")") { + DYNAMIC_SECTION("increment (" << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ", prefix=" << prefix << ")") { uint64_t number; REQUIRE_SUCCESS(memcached_set(memc, S("number"), S("0"), 0, 0)); for (auto i = 1; i <= 10; ++i) { + INFO("iteration " << i); REQUIRE_SUCCESS(memcached_increment(memc, S("number"), 1, &number)); REQUIRE(number == static_cast(i)); } } - DYNAMIC_SECTION("increment by_key (binary=" << binary << ", prefix=" << prefix << ")") { + DYNAMIC_SECTION("increment by_key (" << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ", prefix=" << prefix << ")") { uint64_t number; REQUIRE_SUCCESS(memcached_set_by_key(memc, S("key"), S("number"), S("0"), 0, 0)); @@ -38,11 +44,11 @@ TEST_CASE("memcached_inc_dec") { } } - DYNAMIC_SECTION("increment with initial (binary=" << binary << ", prefix=" << prefix << ")") { + DYNAMIC_SECTION("increment with initial (" << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ", prefix=" << prefix << ")") { uint64_t number; uint64_t initial = GENERATE(0, 456); - if (!binary) { + if (!proto) { REQUIRE_RC(MEMCACHED_INVALID_ARGUMENTS, memcached_increment_with_initial(memc, S("number"), 1, initial, 0, &number)); } else { @@ -53,11 +59,11 @@ TEST_CASE("memcached_inc_dec") { } } - DYNAMIC_SECTION("increment with initial by_key (binary=" << binary << ", prefix=" << prefix << ")") { + DYNAMIC_SECTION("increment with initial by_key (" << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ", prefix=" << prefix << ")") { uint64_t number; uint64_t initial = GENERATE(0, 456); - if (!binary) { + if (!proto) { REQUIRE_RC(MEMCACHED_INVALID_ARGUMENTS, memcached_increment_with_initial_by_key(memc, S("key"), S("number"), 1, initial, 0, &number)); } else { @@ -68,7 +74,7 @@ TEST_CASE("memcached_inc_dec") { } } - DYNAMIC_SECTION("decrement (binary=" << binary << ", prefix=" << prefix << ")") { + DYNAMIC_SECTION("decrement (" << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ", prefix=" << prefix << ")") { uint64_t number; REQUIRE_SUCCESS(memcached_set(memc, S("number"), S("10"), 0, 0)); @@ -78,7 +84,7 @@ TEST_CASE("memcached_inc_dec") { REQUIRE(number == static_cast(i)); } } - DYNAMIC_SECTION("decrement by_key (binary=" << binary << ", prefix=" << prefix << ")") { + DYNAMIC_SECTION("decrement by_key (" << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ", prefix=" << prefix << ")") { uint64_t number; REQUIRE_SUCCESS(memcached_set_by_key(memc, S("key"), S("number"), S("10"), 0, 0)); @@ -88,11 +94,11 @@ TEST_CASE("memcached_inc_dec") { REQUIRE(number == static_cast(i)); } } - DYNAMIC_SECTION("decrement with initial (binary=" << binary << ", prefix=" << prefix << ")") { + DYNAMIC_SECTION("decrement with initial (" << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ", prefix=" << prefix << ")") { uint64_t number; uint64_t initial = GENERATE(987, 456); - if (!binary) { + if (!proto) { REQUIRE_RC(MEMCACHED_INVALID_ARGUMENTS, memcached_decrement_with_initial(memc, S("number"), 1, initial, 0, &number)); } else { @@ -102,11 +108,11 @@ TEST_CASE("memcached_inc_dec") { REQUIRE(number == initial - 123); } } - DYNAMIC_SECTION("decrement with initial by_key (binary=" << binary << ", prefix=" << prefix << ")") { + DYNAMIC_SECTION("decrement with initial by_key (" << (proto ? libmemcached_string_behavior(proto) + sizeof("MEMCACHED_BEHAVIOR") : "ASCII_PROTOCOL") << ", prefix=" << prefix << ")") { uint64_t number; uint64_t initial = GENERATE(987, 456); - if (!binary) { + if (!proto) { REQUIRE_RC(MEMCACHED_INVALID_ARGUMENTS, memcached_decrement_with_initial_by_key(memc, S("key"), S("number"), 1, initial, 0, &number)); } else {