#include <variant>
#include <vector>
+#include "testing/conf.h"
#include "testing/lib/catch.hpp"
#include "testing/lib/random.hpp"
return rc;
}
+#include <cstdlib>
+#include <unistd.h>
+
+class Tempfile {
+public:
+ explicit Tempfile(const char templ_[] = "memc.test.XXXXXX") {
+ *copy(S(templ_)+templ_, fn) = '\0';
+ fd = mkstemp(fn);
+ }
+ ~Tempfile() {
+ close(fd);
+ unlink(fn);
+ }
+ int getFd() const {
+ return fd;
+ }
+ const char *getFn() const {
+ return fn;
+ }
+ bool put(const char *buf, size_t len) const {
+ return static_cast<ssize_t >(len) == write(fd, buf, len);
+ }
+private:
+ char fn[80];
+ int fd;
+};
+
class MemcachedPtr {
public:
memcached_st *memc;
class Malloced {
T *ptr;
public:
+ explicit
Malloced(T *ptr_)
: ptr{ptr_}
{}
auto operator *() {
return ptr;
}
+ auto operator ->() {
+ return ptr;
+ }
};