summaryrefslogtreecommitdiff
path: root/testing/hstox/methods.h
diff options
context:
space:
mode:
Diffstat (limited to 'testing/hstox/methods.h')
-rw-r--r--testing/hstox/methods.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/testing/hstox/methods.h b/testing/hstox/methods.h
new file mode 100644
index 00000000..1a7f3059
--- /dev/null
+++ b/testing/hstox/methods.h
@@ -0,0 +1,47 @@
1#pragma once
2
3#include "util.h"
4
5#include <msgpack.h>
6
7#define CHECK(COND) \
8 do { \
9 if (!(COND)) \
10 return #COND; \
11 } while (0)
12
13#define CHECK_SIZE(ARG, SIZE) \
14 do { \
15 if ((ARG).size != (SIZE)) \
16 return ssprintf("%s:%d: Size of `" #ARG "' expected to be %zu, but was %zu", __FILE__, \
17 __LINE__, SIZE, (ARG).size); \
18 } while (0)
19
20#define CHECK_TYPE(ARG, TYPE) \
21 do { \
22 if ((ARG).type != (TYPE)) \
23 return ssprintf("%s:%d: Type of `" #ARG "' expected to be %s, but was %s", __FILE__, \
24 __LINE__, type_name(TYPE), type_name((ARG).type)); \
25 } while (0)
26
27#define SUCCESS \
28 msgpack_pack_array(res, 0); \
29 if (true)
30
31#define METHOD(TYPE, SERVICE, NAME) \
32 char const *SERVICE##_##NAME(msgpack_object_##TYPE args, msgpack_packer *res)
33
34// These are not defined by msgpack.h, but we need them for uniformity in the
35// METHOD macro.
36typedef int64_t msgpack_object_i64;
37typedef uint64_t msgpack_object_u64;
38
39METHOD(array, Binary, decode);
40METHOD(array, Binary, encode);
41
42char const *call_method(msgpack_object_str name, msgpack_object_array args, msgpack_packer *res);
43int method_cmp(char const *ptr, char const *expected, size_t max_size);
44
45extern char const *const failure;
46extern char const *const pending;
47extern char const *const unimplemented;