Re: [PATCH wayland 3/4] tests: Test wl_array_release

2016-09-20 Thread Pekka Paalanen
On Fri, 16 Sep 2016 15:37:38 -0700
Yong Bakos  wrote:

> From: Yong Bakos 
> 
> array-test.c did not cover wl_array_release, so add one test that specifically
> tests this method.
> 
> Signed-off-by: Yong Bakos 
> ---
>  tests/array-test.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tests/array-test.c b/tests/array-test.c
> index fe53240..a5856fd 100644
> --- a/tests/array-test.c
> +++ b/tests/array-test.c
> @@ -45,6 +45,16 @@ TEST(array_init)
>   }
>  }
>  
> +TEST(array_release)
> +{
> + struct wl_array array;
> + wl_array_init(&array);

Hi

> + array.data = calloc(1, sizeof(int));

This is something one should never do, it is asking for problems. Why
don't you use wl_array_add()?


Thanks,
pq

> + assert(array.data != NULL);
> + wl_array_release(&array);
> + assert(array.data == NULL);
> +}
> +
>  TEST(array_add)
>  {
>   struct mydata {



pgpN4L16WPTfg.pgp
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland 3/4] tests: Test wl_array_release

2016-09-16 Thread Yong Bakos
From: Yong Bakos 

array-test.c did not cover wl_array_release, so add one test that specifically
tests this method.

Signed-off-by: Yong Bakos 
---
 tests/array-test.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/tests/array-test.c b/tests/array-test.c
index fe53240..a5856fd 100644
--- a/tests/array-test.c
+++ b/tests/array-test.c
@@ -45,6 +45,16 @@ TEST(array_init)
}
 }
 
+TEST(array_release)
+{
+   struct wl_array array;
+   wl_array_init(&array);
+   array.data = calloc(1, sizeof(int));
+   assert(array.data != NULL);
+   wl_array_release(&array);
+   assert(array.data == NULL);
+}
+
 TEST(array_add)
 {
struct mydata {
-- 
2.7.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel