[PATCH wayland] Update tests for wl_map changes and add a map_flags test
Jason Ekstrand
jason at jlekstrand.net
Wed Jun 5 07:52:39 PDT 2013
---
tests/connection-test.c | 4 ++--
tests/map-test.c | 54 ++++++++++++++++++++++++++++++++++--------------
tests/os-wrappers-test.c | 2 +-
3 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/tests/connection-test.c b/tests/connection-test.c
index 9a07d71..e284ea0 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -333,7 +333,7 @@ demarshal(struct marshal_data *data, const char *format,
assert(write(data->s[1], msg, size) == size);
assert(wl_connection_read(data->read_connection) == size);
- wl_map_init(&objects);
+ wl_map_init(&objects, WL_MAP_SERVER_SIDE);
object.id = msg[0];
closure = wl_connection_demarshal(data->read_connection,
size, &objects, &message);
@@ -414,7 +414,7 @@ marshal_demarshal(struct marshal_data *data,
assert(wl_connection_read(data->read_connection) == size);
- wl_map_init(&objects);
+ wl_map_init(&objects, WL_MAP_SERVER_SIDE);
object.id = msg[0];
closure = wl_connection_demarshal(data->read_connection,
size, &objects, &message);
diff --git a/tests/map-test.c b/tests/map-test.c
index 28a48c2..3df374c 100644
--- a/tests/map-test.c
+++ b/tests/map-test.c
@@ -31,10 +31,10 @@ TEST(map_insert_new)
struct wl_map map;
uint32_t i, j, k, a, b, c;
- wl_map_init(&map);
- i = wl_map_insert_new(&map, WL_MAP_SERVER_SIDE, &a);
- j = wl_map_insert_new(&map, WL_MAP_SERVER_SIDE, &b);
- k = wl_map_insert_new(&map, WL_MAP_SERVER_SIDE, &c);
+ wl_map_init(&map, WL_MAP_SERVER_SIDE);
+ i = wl_map_insert_new(&map, 0, &a);
+ j = wl_map_insert_new(&map, 0, &b);
+ k = wl_map_insert_new(&map, 0, &c);
assert(i == WL_SERVER_ID_START);
assert(j == WL_SERVER_ID_START + 1);
assert(k == WL_SERVER_ID_START + 2);
@@ -42,8 +42,10 @@ TEST(map_insert_new)
assert(wl_map_lookup(&map, i) == &a);
assert(wl_map_lookup(&map, j) == &b);
assert(wl_map_lookup(&map, k) == &c);
+ wl_map_release(&map);
- i = wl_map_insert_new(&map, WL_MAP_CLIENT_SIDE, &a);
+ wl_map_init(&map, WL_MAP_CLIENT_SIDE);
+ i = wl_map_insert_new(&map, 0, &a);
assert(i == 0);
assert(wl_map_lookup(&map, i) == &a);
@@ -55,13 +57,13 @@ TEST(map_insert_at)
struct wl_map map;
uint32_t a, b, c;
- wl_map_init(&map);
- assert(wl_map_insert_at(&map, WL_MAP_SERVER_SIDE, &a) == 0);
- assert(wl_map_insert_at(&map, WL_MAP_SERVER_SIDE + 3, &b) == -1);
- assert(wl_map_insert_at(&map, WL_MAP_SERVER_SIDE + 1, &c) == 0);
+ wl_map_init(&map, WL_MAP_CLIENT_SIDE);
+ assert(wl_map_insert_at(&map, 0, WL_SERVER_ID_START, &a) == 0);
+ assert(wl_map_insert_at(&map, 0, WL_SERVER_ID_START + 3, &b) == -1);
+ assert(wl_map_insert_at(&map, 0, WL_SERVER_ID_START + 1, &c) == 0);
- assert(wl_map_lookup(&map, WL_MAP_SERVER_SIDE) == &a);
- assert(wl_map_lookup(&map, WL_MAP_SERVER_SIDE + 1) == &c);
+ assert(wl_map_lookup(&map, WL_SERVER_ID_START) == &a);
+ assert(wl_map_lookup(&map, WL_SERVER_ID_START + 1) == &c);
wl_map_release(&map);
}
@@ -71,10 +73,10 @@ TEST(map_remove)
struct wl_map map;
uint32_t i, j, k, l, a, b, c, d;
- wl_map_init(&map);
- i = wl_map_insert_new(&map, WL_MAP_SERVER_SIDE, &a);
- j = wl_map_insert_new(&map, WL_MAP_SERVER_SIDE, &b);
- k = wl_map_insert_new(&map, WL_MAP_SERVER_SIDE, &c);
+ wl_map_init(&map, WL_MAP_SERVER_SIDE);
+ i = wl_map_insert_new(&map, 0, &a);
+ j = wl_map_insert_new(&map, 0, &b);
+ k = wl_map_insert_new(&map, 0, &c);
assert(i == WL_SERVER_ID_START);
assert(j == WL_SERVER_ID_START + 1);
assert(k == WL_SERVER_ID_START + 2);
@@ -87,9 +89,29 @@ TEST(map_remove)
assert(wl_map_lookup(&map, j) == NULL);
/* Verify that we insert d at the hole left by removing b */
- l = wl_map_insert_new(&map, WL_MAP_SERVER_SIDE, &d);
+ l = wl_map_insert_new(&map, 0, &d);
assert(l == WL_SERVER_ID_START + 1);
assert(wl_map_lookup(&map, l) == &d);
wl_map_release(&map);
}
+
+TEST(map_flags)
+{
+ struct wl_map map;
+ uint32_t i, j, a, b;
+
+ wl_map_init(&map, WL_MAP_SERVER_SIDE);
+ i = wl_map_insert_new(&map, 0, &a);
+ j = wl_map_insert_new(&map, 1, &b);
+ assert(i == WL_SERVER_ID_START);
+ assert(j == WL_SERVER_ID_START + 1);
+
+ assert(wl_map_lookup(&map, i) == &a);
+ assert(wl_map_lookup(&map, j) == &b);
+
+ assert(wl_map_lookup_flags(&map, i) == 0);
+ assert(wl_map_lookup_flags(&map, j) == 1);
+
+ wl_map_release(&map);
+}
diff --git a/tests/os-wrappers-test.c b/tests/os-wrappers-test.c
index 77af873..2717253 100644
--- a/tests/os-wrappers-test.c
+++ b/tests/os-wrappers-test.c
@@ -248,7 +248,7 @@ marshal_demarshal(struct marshal_data *data,
assert(wl_connection_read(data->read_connection) == size);
- wl_map_init(&objects);
+ wl_map_init(&objects, WL_MAP_SERVER_SIDE);
object.id = msg[0];
closure = wl_connection_demarshal(data->read_connection,
size, &objects, &message);
--
1.8.1.4
More information about the wayland-devel
mailing list