diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-11-24 22:17:44 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-11-24 22:17:44 -0800 |
| commit | e1dc8358c8515ec456e255585e2952c6c01b62ea (patch) | |
| tree | 757ed88b70c05d3ad53ec9e6355cd86384f50fa9 /tests | |
| parent | 5ea2a1845f3393e91d6d102a8a89f339dd24f467 (diff) | |
| download | nng-e1dc8358c8515ec456e255585e2952c6c01b62ea.tar.gz nng-e1dc8358c8515ec456e255585e2952c6c01b62ea.tar.bz2 nng-e1dc8358c8515ec456e255585e2952c6c01b62ea.zip | |
Convert list to new test framework; detached node fixes.
List nodes that are not part of a list should return NULL when
asking for the next or previous item.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | tests/list.c | 102 |
2 files changed, 0 insertions, 103 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a662d495..e3cbc5ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -132,7 +132,6 @@ add_nng_test(inproc 5) add_nng_test(ipc 5) add_nng_test(ipcsupp 10) add_nng_test(ipcwinsec 5) -add_nng_test(list 5) add_nng_test(message 5) add_nng_test(multistress 60) add_nng_test(nonblock 60) diff --git a/tests/list.c b/tests/list.c deleted file mode 100644 index b0da1196..00000000 --- a/tests/list.c +++ /dev/null @@ -1,102 +0,0 @@ -// -// Copyright 2016 Garrett D'Amore <garrett@damore.org> -// -// This software is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -#include "core/list.c" -#include "convey.h" -#include "stubs.h" - -typedef struct { - int pad[2]; - nni_list_node nodea; - nni_list_node nodeb; -} mystruct; - -TestMain("Linked Lists", { - Convey("Given a couple lists", { - nni_list alist; - nni_list blist; - - NNI_LIST_INIT(&alist, mystruct, nodea); - NNI_LIST_INIT(&blist, mystruct, nodeb); - - So(alist.ll_offset == 8); - So(blist.ll_offset == (8 + sizeof (nni_list_node))); - - Convey("The list starts empty", { - So(nni_list_first(&alist) == NULL); - So(nni_list_last(&blist) == NULL); - }); - - Convey("And we can add an item", { - mystruct item; - - NNI_LIST_NODE_INIT(&item.nodea); - NNI_LIST_NODE_INIT(&item.nodeb); - - nni_list_append(&alist, &item); - - Convey("It is the first item", { - So(nni_list_first(&alist) == &item); - }); - Convey("It is the last item", { - So(nni_list_last(&alist) == &item); - }); - Convey("It is the only item", { - So(nni_list_next(&alist, &item) == NULL); - So(nni_list_prev(&alist, &item) == NULL); - }); - Convey("It isn't on the other list", { - So(nni_list_first(&blist) == NULL); - So(nni_list_last(&blist) == NULL); - }); - Convey("We can remove it", { - nni_list_remove(&alist, &item); - So(nni_list_first(&alist) == NULL); - So(nni_list_last(&alist) == NULL); - }); - }); - - Convey("We can add two items", { - mystruct item1; - mystruct item2; - - NNI_LIST_NODE_INIT(&item1.nodea); - NNI_LIST_NODE_INIT(&item1.nodeb); - NNI_LIST_NODE_INIT(&item2.nodea); - NNI_LIST_NODE_INIT(&item2.nodeb); - - nni_list_append(&alist, &item1); - nni_list_append(&alist, &item2); - - So(nni_list_first(&alist) == &item1); - So(nni_list_last(&alist) == &item2); - So(nni_list_next(&alist, &item1) == &item2); - So(nni_list_prev(&alist, &item2) == &item1); - - So(nni_list_next(&alist, &item2) == NULL); - So(nni_list_prev(&alist, &item1) == NULL); - - Convey("Removing the first works", { - nni_list_remove(&alist, &item1); - So(nni_list_first(&alist) == &item2); - So(nni_list_last(&alist) == &item2); - So(nni_list_next(&alist, &item2) == NULL); - So(nni_list_prev(&alist, &item2) == NULL); - }); - - Convey("Removing the second works", { - nni_list_remove(&alist, &item2); - So(nni_list_first(&alist) == &item1); - So(nni_list_last(&alist) == &item1); - So(nni_list_next(&alist, &item1) == NULL); - So(nni_list_prev(&alist, &item1) == NULL); - }); - }); - }); -}) |
