From 978d872307599402a627619a5bcda8eaa57563c4 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 25 Mar 2021 16:29:23 -0400 Subject: [PATCH] [nctabbed] get Add test working --- src/lib/tabbed.c | 4 ++-- src/tests/tabbed.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lib/tabbed.c b/src/lib/tabbed.c index 20fc7b2e0..7529e88f9 100644 --- a/src/lib/tabbed.c +++ b/src/lib/tabbed.c @@ -390,8 +390,8 @@ void nctabbed_destroy(nctabbed* nt){ nctab* t = nt->leftmost; nctab* tmp; if(t){ - t->prev->next = t->next; - t->next->prev = t->prev; + t->prev->next = NULL; + t->next->prev = NULL; } while(t){ tmp = t->next; diff --git a/src/tests/tabbed.cpp b/src/tests/tabbed.cpp index f20ef82d6..0e8432811 100644 --- a/src/tests/tabbed.cpp +++ b/src/tests/tabbed.cpp @@ -61,7 +61,7 @@ TEST_CASE("Tabbed") { REQUIRE(nullptr != nt); CHECK(0 == nctabbed_tabcount(nt)); auto t1 = nctabbed_add(nt, nullptr, nullptr, tabbedcb, "amazingtab123", nullptr); - CHECK(nullptr != t1); + REQUIRE(nullptr != t1); CHECK(t1 == nctabbed_selected(nt)); CHECK(t1 == nctabbed_leftmost(nt)); CHECK(1 == nctabbed_tabcount(nt)); @@ -70,7 +70,7 @@ TEST_CASE("Tabbed") { CHECK(nullptr == nctab_userptr(t1)); CHECK(0 == strcmp("amazingtab123", nctab_name(t1))); auto t2 = nctabbed_add(nt, nullptr, nullptr, nullptr, "nullcbtab", nullptr); - CHECK(nullptr != t2); + REQUIRE(nullptr != t2); CHECK(t1 == nctabbed_selected(nt)); CHECK(t1 == nctabbed_leftmost(nt)); CHECK(2 == nctabbed_tabcount(nt)); @@ -80,24 +80,26 @@ TEST_CASE("Tabbed") { CHECK(t1 == nctab_prev(t2)); // this one gets put in the middle auto t3 = nctabbed_add(nt, nullptr, nullptr, tabbedcb, "tab3", nullptr); - CHECK(nullptr != t3); + REQUIRE(nullptr != t3); CHECK(3 == nctabbed_tabcount(nt)); CHECK(t2 == nctab_next(t3)); CHECK(t1 == nctab_prev(t3)); - // this one at the end + CHECK(t1 == nctab_next(t2)); + CHECK(t2 == nctab_prev(t1)); + // now the last auto t4 = nctabbed_add(nt, t2, t1, tabbedcb, "tab4", nullptr); - CHECK(nullptr != t4); + REQUIRE(nullptr != t4); CHECK(4 == nctabbed_tabcount(nt)); CHECK(t1 == nctab_next(t4)); CHECK(t2 == nctab_prev(t4)); // second to last auto t5 = nctabbed_add(nt, nullptr, t4, tabbedcb, "tab5", nullptr); - CHECK(nullptr != t5); + REQUIRE(nullptr != t5); CHECK(t4 == nctab_next(t5)); CHECK(t2 == nctab_prev(t5)); // second auto t6 = nctabbed_add(nt, t1, nullptr, tabbedcb, "tab6", nullptr); - CHECK(nullptr != t6); + REQUIRE(nullptr != t6); CHECK(t3 == nctab_next(t6)); CHECK(t1 == nctab_prev(t6)); nctabbed_destroy(nt);