bin: consolidate clients
[awesomized/libmemcached] / test / tests / memcached / options.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/MemcachedCluster.hpp"
3
4 #include "libmemcached/options.hpp"
5 #include "libmemcached/common.h"
6 #include "libmemcached/array.h"
7
8
9 #include <libgen.h>
10
11 #define FIXTURES_OPTIONS_CONFIG "/../../fixtures/options.config"
12
13 TEST_CASE("memcached_options") {
14 MemcachedPtr memc;
15 LoneReturnMatcher test{*memc};
16
17 char cpp_file[] = __FILE__, buf[1024], *dir = dirname(cpp_file);
18 auto file = string(dir) + FIXTURES_OPTIONS_CONFIG;
19 auto config = "--CONFIGURE-FILE=\"" + file + "\"";
20
21 REQUIRE_RC(MEMCACHED_INVALID_ARGUMENTS, memcached_parse_configure_file(**memc, nullptr, 123));
22 REQUIRE_RC(MEMCACHED_INVALID_ARGUMENTS, memcached_parse_configure_file(**memc, file.c_str(), 0));
23 REQUIRE_RC(MEMCACHED_ERRNO, memcached_parse_configure_file(**memc, S("foobar.baz")));
24 REQUIRE_SUCCESS(memcached_parse_configure_file(**memc, file.c_str(), file.length()));
25
26 REQUIRE_SUCCESS(libmemcached_check_configuration(config.c_str(), config.length(), buf, sizeof(buf) - 1));
27 REQUIRE_RC(MEMCACHED_PARSE_ERROR, libmemcached_check_configuration(S("foo bar"), nullptr, 0));
28 }