[PATCH wayland 2/2] tests: Add test for wl_list_length
Pekka Paalanen
ppaalanen at gmail.com
Wed Aug 31 12:14:44 UTC 2016
On Fri, 26 Aug 2016 10:02:23 +0100
Eric Engestrom <eric.engestrom at imgtec.com> wrote:
> On Thu, Aug 25, 2016 at 04:12:34PM -0700, Yong Bakos wrote:
> > From: Yong Bakos <ybakos at humanoriented.com>
> >
> > list-test.c did not cover wl_list_length, so add one test that specifically
> > tests this method.
> >
> > Signed-off-by: Yong Bakos <ybakos at humanoriented.com>
> > ---
> > tests/list-test.c | 13 +++++++++++++
> > 1 file changed, 13 insertions(+)
> >
> > diff --git a/tests/list-test.c b/tests/list-test.c
> > index 21ca4ec..0752618 100644
> > --- a/tests/list-test.c
> > +++ b/tests/list-test.c
> > @@ -57,6 +57,19 @@ TEST(list_insert)
> > assert(e.link.prev == &list);
> > }
> >
> > +TEST(list_length)
> > +{
> > + struct wl_list list;
> > + struct element e;
> > +
> > + wl_list_init(&list);
> > + assert(wl_list_length(&list) == 0);
> > + wl_list_insert(&list, &e.link);
> > + assert(wl_list_length(&list) == 1);
>
> What about a second insert(e) to make sure duplicates are handled
> correctly?
Duplicates are not handled, that would cause a list corruption by
design.
We also cannot add checks against it, because wl_list_insert() needs to
work on an uninitialized link (inscribed in ABI by now).
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Thanks,
pq
> With or without this, the series is
> Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
>
> > + wl_list_remove(&e.link);
> > + assert(wl_list_length(&list) == 0);
> > +}
> > +
> > TEST(list_iterator)
> > {
> > struct wl_list list;
> > --
> > 2.7.2
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160831/1fd17c04/attachment.sig>
More information about the wayland-devel
mailing list