array-test: Include wayland-util.h and simplify init test

Include wayland-util.h in addition to wayland-private.h, to be more explicit
about where wl_array is defined.

Remove the useless repeated testing of wl_array_init, because if it fails once
out of thousands of iterations we're all doomed anyway.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
[Pekka: add the memset]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Yong Bakos 2016-09-27 13:03:50 -05:00 committed by Pekka Paalanen
parent f04f218781
commit a1ab2c03ae

View file

@ -25,24 +25,22 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <string.h>
#include "wayland-util.h"
#include "wayland-private.h" #include "wayland-private.h"
#include "test-runner.h" #include "test-runner.h"
TEST(array_init) TEST(array_init)
{ {
const int iterations = 4122; /* this is arbitrary */ struct wl_array array;
int i;
/* Init array an arbitray amount of times and verify the /* fill with garbage to emulate uninitialized memory */
* defaults are sensible. */ memset(&array, 0x57, sizeof array);
for (i = 0; i < iterations; i++) { wl_array_init(&array);
struct wl_array array; assert(array.size == 0);
wl_array_init(&array); assert(array.alloc == 0);
assert(array.size == 0); assert(array.data == 0);
assert(array.alloc == 0);
assert(array.data == 0);
}
} }
TEST(array_release) TEST(array_release)