From b0cd65deacb99c9cf0ca5c0c741307eb1f4a9c5e Mon Sep 17 00:00:00 2001 From: Yong Bakos Date: Tue, 8 Nov 2016 07:56:30 -0800 Subject: [PATCH] tests: Test wl_interface_equal 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 [Pekka: add assert(&wl_registry_interface != ©);] Signed-off-by: Pekka Paalanen --- Makefile.am | 3 +++ tests/interface-test.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/interface-test.c diff --git a/Makefile.am b/Makefile.am index eea5aae..87bab0d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -151,6 +151,7 @@ built_test_programs = \ 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..5290bb6 --- /dev/null +++ b/tests/interface-test.c @@ -0,0 +1,50 @@ +/* + * 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 + +#include "wayland-client.h" +#include "wayland-private.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_registry_interface != ©); + + assert(wl_interface_equal(&wl_registry_interface, + &wl_registry_interface)); + assert(wl_interface_equal(&wl_registry_interface, ©)); + assert(wl_interface_equal(&wl_registry_interface, + &fake_registry)); + assert(!wl_interface_equal(&wl_registry_interface, &fake)); +}