bin: consolidate clients
[awesomized/libmemcached] / test / tests / memcached / exist.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/MemcachedCluster.hpp"
3
4 TEST_CASE("memcached_exist") {
5 MemcachedCluster test;
6 auto memc = &test.memc;
7 auto binary = GENERATE(0, 1);
8
9 test.enableBinaryProto(binary);
10 INFO("binary: " << binary);
11
12 SECTION("initial not found") {
13 REQUIRE_RC(MEMCACHED_NOTFOUND,memcached_exist(memc, S("frog")));
14 }
15
16 SECTION("set found") {
17 REQUIRE_SUCCESS(memcached_set(memc, S("frog"), S("frog"), 0, 0));
18 REQUIRE_SUCCESS(memcached_exist(memc, S("frog")));
19
20 SECTION("deleted not found") {
21 REQUIRE_SUCCESS(memcached_delete(memc, S("frog"), 0));
22 REQUIRE_RC(MEMCACHED_NOTFOUND, memcached_exist(memc, S("frog")));
23 }
24 }
25
26 SECTION("by key") {
27 SECTION("initial not found") {
28 REQUIRE_RC(MEMCACHED_NOTFOUND, memcached_exist_by_key(memc, S("master"), S("frog")));
29 }
30
31 SECTION("set found") {
32 REQUIRE_SUCCESS(memcached_set_by_key(memc, S("master"), S("frog"), S("frog"), 0, 0));
33 REQUIRE_SUCCESS(memcached_exist_by_key(memc, S("master"), S("frog")));
34
35 SECTION("deleted not found") {
36 REQUIRE_SUCCESS(memcached_delete_by_key(memc, S("master"), S("frog"), 0));
37 REQUIRE_RC(MEMCACHED_NOTFOUND, memcached_exist_by_key(memc, S("master"), S("frog")));
38 }
39 }
40 }
41
42 }