summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYong Bakos <ybakos@humanoriented.com>2016-11-23 07:38:01 -0800
committerDaniel Stone <daniels@collabora.com>2017-01-26 14:49:55 +0000
commit8fe8a2bb1e2b893bd39899f7481d5cf5fa303b29 (patch)
tree864afdad0808501a4e4d9d00c59f8e297007f609
parente89d0a66843eb3cb4d888c594ad87ef731e51697 (diff)
tests: Test wl_argument_from_va_list
connection-test.c did not cover wl_argument_from_va_list, so add one test that specifically tests this method. Signed-off-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
-rw-r--r--tests/connection-test.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/connection-test.c b/tests/connection-test.c
index 3e34f77..1c688f1 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -130,6 +130,41 @@ TEST(connection_queue)
close(s[1]);
}
+static void
+va_list_wrapper(const char *signature, union wl_argument *args, int count, ...)
+{
+ va_list ap;
+ va_start(ap, count);
+ wl_argument_from_va_list(signature, args, count, ap);
+ va_end(ap);
+}
+
+TEST(argument_from_va_list)
+{
+ union wl_argument args[WL_CLOSURE_MAX_ARGS];
+ struct wl_object fake_object;
+ struct wl_array fake_array;
+
+ va_list_wrapper("i", args, 1, 100);
+ assert(args[0].i == 100);
+
+ va_list_wrapper("is", args, 2, 101, "value");
+ assert(args[0].i == 101);
+ assert(strcmp(args[1].s, "value") == 0);
+
+ va_list_wrapper("?iuf?sonah", args, 8,
+ 102, 103, wl_fixed_from_int(104), "value",
+ &fake_object, 105, &fake_array, 106);
+ assert(args[0].i == 102);
+ assert(args[1].u == 103);
+ assert(args[2].f == wl_fixed_from_int(104));
+ assert(strcmp(args[3].s, "value") == 0);
+ assert(args[4].o == &fake_object);
+ assert(args[5].n == 105);
+ assert(args[6].a == &fake_array);
+ assert(args[7].h == 106);
+}
+
struct marshal_data {
struct wl_connection *read_connection;
struct wl_connection *write_connection;