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 <ybakos@humanoriented.com>
[Pekka: add assert(&wl_registry_interface != &copy);]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Yong Bakos 2016-11-08 07:56:30 -08:00 committed by Pekka Paalanen
parent 0cdc3229b0
commit b0cd65deac
2 changed files with 53 additions and 0 deletions

View File

@ -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

50
tests/interface-test.c Normal file
View File

@ -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 <assert.h>
#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 != &copy);
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));
}