testing: parser
[awesomized/libmemcached] / test / tests / memcached / parser.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/env.hpp"
3
4 TEST_CASE("memcached_parser") {
5 SECTION("fail: null string") {
6 REQUIRE_FALSE(memcached(nullptr, 123));
7 }
8 SECTION("fail: zero length") {
9 REQUIRE_FALSE(memcached("123", 0));
10 }
11 SECTION("success: localhost") {
12 auto mc = memcached(S("--server=localhost"));
13 REQUIRE(mc);
14 memcached_free(mc);
15 }
16 SECTION("env") {
17 SECTION("success: localhost") {
18 SET_ENV(success_localhost, "LIBMEMCACHED", "--server=localhost");
19 auto mc = memcached(nullptr, 0);
20 REQUIRE(mc);
21 memcached_free(mc);
22 }
23 SECTION("success: empty string") {
24 SET_ENV(success_empty_string, "LIBMEMCACHED", "");
25 auto mc = memcached(nullptr, 0);
26 REQUIRE(mc);
27 memcached_free(mc);
28 }
29 SECTION("fail: extra quotes") {
30 SET_ENV(fail_extra_quotes, "LIBMEMCACHED", "\"--server=localhost\"");
31 REQUIRE_FALSE(memcached(nullptr, 0));
32 }
33 }
34 }