[RFC wayland 1/1] tests: Test wl_argument_from_va_list

Yong Bakos junk at humanoriented.com
Sun Nov 13 19:14:30 UTC 2016


From: Yong Bakos <ybakos at humanoriented.com>

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 at humanoriented.com>
---
 tests/connection-test.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/connection-test.c b/tests/connection-test.c
index 3e34f77..4d5d67e 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -130,6 +130,27 @@ 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];
+
+	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);
+}
+
 struct marshal_data {
 	struct wl_connection *read_connection;
 	struct wl_connection *write_connection;
--
2.7.2



More information about the wayland-devel mailing list