mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
tests: Test wl_message_count_arrays
message-test.c did not cover wl_message_count_arrays, so add one test that specifically tests this method. Note that this exposes wl_message_count_arrays in a private header (wayland-private.h), and removes the `static` modifier of the implementation. Signed-off-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
66a26aeb2a
commit
9618087c6a
3 changed files with 41 additions and 1 deletions
|
|
@ -392,7 +392,7 @@ wl_connection_queue(struct wl_connection *connection,
|
|||
return wl_buffer_put(&connection->out, data, count);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
wl_message_count_arrays(const struct wl_message *message)
|
||||
{
|
||||
int i, arrays;
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ get_next_argument(const char *signature, struct argument_details *details);
|
|||
int
|
||||
arg_count_for_signature(const char *signature);
|
||||
|
||||
int
|
||||
wl_message_count_arrays(const struct wl_message *message);
|
||||
|
||||
int
|
||||
wl_message_get_since(const struct wl_message *message);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,3 +51,40 @@ TEST(message_version)
|
|||
messages[i].expected_version);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(message_count_arrays)
|
||||
{
|
||||
unsigned int i;
|
||||
struct wl_message fake_messages[] = {
|
||||
{ "empty", "", NULL },
|
||||
{ "non_present", "iufsonh", NULL },
|
||||
{ "leading", "aiufsonh", NULL},
|
||||
{ "trailing", "iufsonha", NULL },
|
||||
{ "middle", "iufasonh", NULL },
|
||||
{ "multiple", "aaiufaasonhaa", NULL },
|
||||
{ "leading_version", "2aaiufaasonhaa", NULL },
|
||||
{ "among_nullables", "iufsa?oa?nah", NULL },
|
||||
{ "all_mixed", "2aiufas?oa?na", NULL },
|
||||
};
|
||||
const struct {
|
||||
const struct wl_message *message;
|
||||
int expected_array_count;
|
||||
} messages[] = {
|
||||
{ &wl_pointer_interface.events[WL_POINTER_ENTER], 0 },
|
||||
{ &wl_keyboard_interface.events[WL_KEYBOARD_ENTER], 1 },
|
||||
{ &fake_messages[0], 0 },
|
||||
{ &fake_messages[1], 0 },
|
||||
{ &fake_messages[2], 1 },
|
||||
{ &fake_messages[3], 1 },
|
||||
{ &fake_messages[4], 1 },
|
||||
{ &fake_messages[5], 6 },
|
||||
{ &fake_messages[6], 6 },
|
||||
{ &fake_messages[7], 3 },
|
||||
{ &fake_messages[8], 4 }
|
||||
};
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(messages); ++i) {
|
||||
assert(wl_message_count_arrays(messages[i].message) ==
|
||||
messages[i].expected_array_count);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue