update TODO
[awesomized/libmemcached] / test / tests / memcached / value_flags.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/MemcachedCluster.hpp"
3
4 TEST_CASE("memcached_value_flags") {
5 auto test = MemcachedCluster::mixed();
6 auto memc = &test.memc;
7 const auto size = 1048064lu;
8 auto blob = make_unique<char[]>(size);
9
10 SECTION("set & get flags") {
11 uint32_t flag = GENERATE(123, 456, 789, UINT32_MAX);
12
13 REQUIRE_SUCCESS(memcached_set(memc, S(__func__), blob.get(), size, 0, flag));
14
15 size_t len;
16 uint32_t flg;
17 memcached_return_t rc;
18 Malloced val(memcached_get(memc, S(__func__), &len, &flg, &rc));
19 REQUIRE_SUCCESS(rc);
20 REQUIRE(*val);
21 REQUIRE(len == size);
22 REQUIRE(flg == flag);
23
24 len = strlen(__func__);
25 auto fun = __func__;
26 char key[MEMCACHED_MAX_KEY];
27 memcpy(key, fun, strlen(fun) + 1);
28 const char *keys[1] = {key};
29 REQUIRE_SUCCESS(memcached_mget(memc, keys, &len, 1));
30 while (auto rv = memcached_fetch(memc, key, nullptr, &len, &flg, &rc)) {
31 REQUIRE_SUCCESS(rc);
32 REQUIRE(len == size);
33 REQUIRE_FALSE(memcmp(rv, blob.get(), len));
34 REQUIRE(flag == flg);
35 free(rv);
36 }
37 REQUIRE_RC(MEMCACHED_END, rc);
38 }
39 }