[PATCH wayland] tests: Test wl_interface_equal

Yong Bakos junk at humanoriented.com
Tue Nov 8 15:52:31 UTC 2016


From: Yong Bakos <ybakos at humanoriented.com>

The test suite did not cover wl_interface_equal, so add one test that
specifically tests this method. Add the new test to Makefile.am.

Signed-off-by: Yong Bakos <ybakos at humanoriented.com>
---
 Makefile.am            |  3 +++
 tests/interface-test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 tests/interface-test.c

diff --git a/Makefile.am b/Makefile.am
index 3eb6fd5..88139b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -151,6 +151,7 @@ TESTS =						\
 	connection-test				\
 	event-loop-test				\
 	fixed-test				\
+	interface-test				\
 	list-test				\
 	map-test				\
 	os-wrappers-test			\
@@ -203,6 +204,8 @@ event_loop_test_SOURCES = tests/event-loop-test.c
 event_loop_test_LDADD = libtest-runner.la
 fixed_test_SOURCES = tests/fixed-test.c
 fixed_test_LDADD = libtest-runner.la
+interface_test_SOURCES = tests/interface-test.c
+interface_test_LDADD = libtest-runner.la
 list_test_SOURCES = tests/list-test.c
 list_test_LDADD = libtest-runner.la
 map_test_SOURCES = tests/map-test.c
diff --git a/tests/interface-test.c b/tests/interface-test.c
new file mode 100644
index 0000000..cfb7173
--- /dev/null
+++ b/tests/interface-test.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2016 Yong Bakos
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <assert.h>
+
+#include "wayland-client.h"
+#include "wayland-private.h"
+#include "wayland-server.h"
+#include "test-runner.h"
+
+TEST(interface_equal)
+{
+	const struct wl_interface fake = {
+		"fake", 1, 0, NULL, 0, NULL
+	};
+	const struct wl_interface fake_registry = {
+		"wl_registry", 1, 0, NULL, 0, NULL
+	};
+	const struct wl_interface copy = wl_registry_interface;
+
+	assert(wl_interface_equal(&wl_registry_interface,
+				  &wl_registry_interface));
+	assert(wl_interface_equal(&wl_registry_interface, &copy));
+	assert(wl_interface_equal(&wl_registry_interface,
+				  &fake_registry));
+	assert(!wl_interface_equal(&wl_registry_interface, &fake));
+}
-- 
2.7.2



More information about the wayland-devel mailing list