1 #include "test/lib/common.hpp"
2 #include "test/lib/MemcachedCluster.hpp"
4 TEST_CASE("memcached_append") {
5 pair
<string
, MemcachedCluster
> tests
[] = {
6 {"bin_mixed", MemcachedCluster::mixed()},
7 {"mixed", MemcachedCluster::mixed()}
10 tests
[0].second
.enableBinaryProto();
12 LOOPED_SECTION(tests
) {
13 auto memc
= &test
.memc
;
16 const char *values
[] = {
17 "one", "two", "three", "four"
20 for (auto key
: values
) {
23 REQUIRE_SUCCESS(memcached_set(memc
, S(key
), S(key
), 0, 0));
24 for (auto value
: values
) {
25 REQUIRE_SUCCESS(memcached_append(memc
, S(key
), S(value
), 0, 0));
29 memcached_return_t rc
;
32 Malloced
got(memcached_get(memc
, S(key
), &len
, &flags
, &rc
));
40 vector
<uint32_t> store_list
{ 23, 56, 499, 98, 32847, 0 };
41 const size_t raw_len
= sizeof(decltype(store_list
)::value_type
) * store_list
.size();
42 const char *raw_ptr
= reinterpret_cast<char *>(store_list
.data());
44 REQUIRE_SUCCESS(memcached_set(memc
, S(__func__
), nullptr, 0, 0, 0));
46 for (auto item
: store_list
) {
47 auto val
= reinterpret_cast<char *>(&item
);
48 REQUIRE_SUCCESS(memcached_append(memc
, S(__func__
), val
, sizeof(item
), 0, 0));
51 memcached_return_t rc
;
54 Malloced
got(memcached_get(memc
, S(__func__
), &len
, &flags
, &rc
));
56 REQUIRE(len
== raw_len
);
57 REQUIRE(string
{raw_ptr
, raw_len
} == string
{*got
, len
});