mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-12-20 19:50:08 +01:00
tests: Simplify connection tests a bit
This commit is contained in:
parent
efab74e956
commit
d86718fc33
1 changed files with 6 additions and 9 deletions
|
|
@ -147,17 +147,17 @@ struct marshal_data {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
marshal(struct marshal_data *data,
|
marshal(struct marshal_data *data, const char *format, int size, ...)
|
||||||
const struct wl_message *message, int size, ...)
|
|
||||||
{
|
{
|
||||||
struct wl_closure *closure;
|
struct wl_closure *closure;
|
||||||
static const int opcode = 4444;
|
static const int opcode = 4444;
|
||||||
static struct wl_object sender = { NULL, NULL, 1234 };
|
static struct wl_object sender = { NULL, NULL, 1234 };
|
||||||
|
struct wl_message message = { "test", format, NULL };
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, size);
|
va_start(ap, size);
|
||||||
closure = wl_connection_vmarshal(data->connection,
|
closure = wl_connection_vmarshal(data->connection,
|
||||||
&sender, opcode, ap, message);
|
&sender, opcode, ap, &message);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
assert(closure);
|
assert(closure);
|
||||||
|
|
@ -176,20 +176,17 @@ marshal(struct marshal_data *data,
|
||||||
|
|
||||||
TEST(connection_marshal)
|
TEST(connection_marshal)
|
||||||
{
|
{
|
||||||
static const struct wl_message int_message = { "test", "i", NULL };
|
|
||||||
static const struct wl_message uint_message = { "test", "u", NULL };
|
|
||||||
static const struct wl_message string_message = { "test", "s", NULL };
|
|
||||||
struct marshal_data data;
|
struct marshal_data data;
|
||||||
|
|
||||||
data.connection = setup(data.s, &data.mask);
|
data.connection = setup(data.s, &data.mask);
|
||||||
|
|
||||||
marshal(&data, &int_message, 12, 42);
|
marshal(&data, "i", 12, 42);
|
||||||
assert(data.buffer[2] == 42);
|
assert(data.buffer[2] == 42);
|
||||||
|
|
||||||
marshal(&data, &uint_message, 12, 55);
|
marshal(&data, "u", 12, 55);
|
||||||
assert(data.buffer[2] == 55);
|
assert(data.buffer[2] == 55);
|
||||||
|
|
||||||
marshal(&data, &string_message, 20, "frappo");
|
marshal(&data, "s", 20, "frappo");
|
||||||
assert(data.buffer[2] == 7);
|
assert(data.buffer[2] == 7);
|
||||||
assert(strcmp((char *) &data.buffer[3], "frappo") == 0);
|
assert(strcmp((char *) &data.buffer[3], "frappo") == 0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue