X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Ftest-list.c;h=5cba959d23ed5943b70aaa71fcf03f917f51d9df;hb=003ce655b7116d18c86a74c50391e54990346931;hp=0efdbfce42c40592df6f50f246dfddd26fd1f4f4;hpb=d295e8e97acae13552a5b220d3fbcff8201064a2;p=sliver-openvswitch.git diff --git a/tests/test-list.c b/tests/test-list.c index 0efdbfce4..5cba959d2 100644 --- a/tests/test-list.c +++ b/tests/test-list.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011, 2014 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ #include #include "list.h" #include +#include "ovstest.h" #undef NDEBUG #include @@ -55,7 +56,7 @@ check_list(struct list *list, const int values[], size_t n) size_t i; i = 0; - LIST_FOR_EACH (e, struct element, node, list) { + LIST_FOR_EACH (e, node, list) { assert(i < n); assert(e->value == values[i]); i++; @@ -64,7 +65,7 @@ check_list(struct list *list, const int values[], size_t n) assert(i == n); i = 0; - LIST_FOR_EACH_REVERSE (e, struct element, node, list) { + LIST_FOR_EACH_REVERSE (e, node, list) { assert(i < n); assert(e->value == values[n - i - 1]); i++; @@ -73,6 +74,8 @@ check_list(struct list *list, const int values[], size_t n) assert(i == n); assert(list_is_empty(list) == !n); + assert(list_is_singleton(list) == (n == 1)); + assert(list_is_short(list) == (n < 2)); assert(list_size(list) == n); } @@ -84,7 +87,7 @@ print_list(const char *name, struct list *list) struct element *e; printf("%s:", name); - LIST_FOR_EACH (e, struct element, node, list) { + LIST_FOR_EACH (e, node, list) { printf(" %d", e->value); } printf("\n"); @@ -131,7 +134,7 @@ test_list_for_each_safe(void) i = 0; values_idx = 0; n_remaining = n; - LIST_FOR_EACH_SAFE (e, next, struct element, node, &list) { + LIST_FOR_EACH_SAFE (e, next, node, &list) { assert(i < n); if (pattern & (1ul << i)) { list_remove(&e->node); @@ -164,12 +167,12 @@ run_test(void (*function)(void)) printf("."); } -int -main(void) +static void +test_list_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) { run_test(test_list_construction); run_test(test_list_for_each_safe); printf("\n"); - return 0; } +OVSTEST_REGISTER("test-list", test_list_main);