1 #include "test/lib/common.hpp"
2 #include "test/lib/env.hpp"
4 #include "libmemcached/common.h"
5 #include "test/fixtures/parser.hpp"
7 TEST_CASE("memcached_parser") {
8 SECTION("fail: null string") {
9 REQUIRE_FALSE(memcached(nullptr, 123));
11 SECTION("fail: zero length") {
12 REQUIRE_FALSE(memcached("123", 0));
14 SECTION("success: localhost") {
15 auto mc
= memcached(S("--server=localhost"));
20 SECTION("success: localhost") {
21 SET_ENV(success_localhost
, "LIBMEMCACHED", "--server=localhost");
22 auto mc
= memcached(nullptr, 0);
26 SECTION("success: empty string") {
27 SET_ENV(success_empty_string
, "LIBMEMCACHED", "");
28 auto mc
= memcached(nullptr, 0);
32 SECTION("fail: extra quotes") {
33 SET_ENV(fail_extra_quotes
, "LIBMEMCACHED", "\"--server=localhost\"");
34 REQUIRE_FALSE(memcached(nullptr, 0));
39 for (const auto &test
: tests
) {
40 DYNAMIC_SECTION(test
.name
) {
41 for (size_t i
= 0; i
< test
.ntests
; ++i
) {
42 auto &tc
= test
.tests
[i
];
43 DYNAMIC_SECTION(tc
.option
.c_str
) {
44 MemcachedPtr
memc(memcached(tc
.option
.c_str
, tc
.option
.size
));
45 test
.check(*memc
, tc
.result
);