[nctabbed] get Add test working

dankamongmen/libsixel
nick black 4 years ago
parent 7754eed249
commit 978d872307
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -390,8 +390,8 @@ void nctabbed_destroy(nctabbed* nt){
nctab* t = nt->leftmost; nctab* t = nt->leftmost;
nctab* tmp; nctab* tmp;
if(t){ if(t){
t->prev->next = t->next; t->prev->next = NULL;
t->next->prev = t->prev; t->next->prev = NULL;
} }
while(t){ while(t){
tmp = t->next; tmp = t->next;

@ -61,7 +61,7 @@ TEST_CASE("Tabbed") {
REQUIRE(nullptr != nt); REQUIRE(nullptr != nt);
CHECK(0 == nctabbed_tabcount(nt)); CHECK(0 == nctabbed_tabcount(nt));
auto t1 = nctabbed_add(nt, nullptr, nullptr, tabbedcb, "amazingtab123", nullptr); auto t1 = nctabbed_add(nt, nullptr, nullptr, tabbedcb, "amazingtab123", nullptr);
CHECK(nullptr != t1); REQUIRE(nullptr != t1);
CHECK(t1 == nctabbed_selected(nt)); CHECK(t1 == nctabbed_selected(nt));
CHECK(t1 == nctabbed_leftmost(nt)); CHECK(t1 == nctabbed_leftmost(nt));
CHECK(1 == nctabbed_tabcount(nt)); CHECK(1 == nctabbed_tabcount(nt));
@ -70,7 +70,7 @@ TEST_CASE("Tabbed") {
CHECK(nullptr == nctab_userptr(t1)); CHECK(nullptr == nctab_userptr(t1));
CHECK(0 == strcmp("amazingtab123", nctab_name(t1))); CHECK(0 == strcmp("amazingtab123", nctab_name(t1)));
auto t2 = nctabbed_add(nt, nullptr, nullptr, nullptr, "nullcbtab", nullptr); auto t2 = nctabbed_add(nt, nullptr, nullptr, nullptr, "nullcbtab", nullptr);
CHECK(nullptr != t2); REQUIRE(nullptr != t2);
CHECK(t1 == nctabbed_selected(nt)); CHECK(t1 == nctabbed_selected(nt));
CHECK(t1 == nctabbed_leftmost(nt)); CHECK(t1 == nctabbed_leftmost(nt));
CHECK(2 == nctabbed_tabcount(nt)); CHECK(2 == nctabbed_tabcount(nt));
@ -80,24 +80,26 @@ TEST_CASE("Tabbed") {
CHECK(t1 == nctab_prev(t2)); CHECK(t1 == nctab_prev(t2));
// this one gets put in the middle // this one gets put in the middle
auto t3 = nctabbed_add(nt, nullptr, nullptr, tabbedcb, "tab3", nullptr); auto t3 = nctabbed_add(nt, nullptr, nullptr, tabbedcb, "tab3", nullptr);
CHECK(nullptr != t3); REQUIRE(nullptr != t3);
CHECK(3 == nctabbed_tabcount(nt)); CHECK(3 == nctabbed_tabcount(nt));
CHECK(t2 == nctab_next(t3)); CHECK(t2 == nctab_next(t3));
CHECK(t1 == nctab_prev(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); auto t4 = nctabbed_add(nt, t2, t1, tabbedcb, "tab4", nullptr);
CHECK(nullptr != t4); REQUIRE(nullptr != t4);
CHECK(4 == nctabbed_tabcount(nt)); CHECK(4 == nctabbed_tabcount(nt));
CHECK(t1 == nctab_next(t4)); CHECK(t1 == nctab_next(t4));
CHECK(t2 == nctab_prev(t4)); CHECK(t2 == nctab_prev(t4));
// second to last // second to last
auto t5 = nctabbed_add(nt, nullptr, t4, tabbedcb, "tab5", nullptr); auto t5 = nctabbed_add(nt, nullptr, t4, tabbedcb, "tab5", nullptr);
CHECK(nullptr != t5); REQUIRE(nullptr != t5);
CHECK(t4 == nctab_next(t5)); CHECK(t4 == nctab_next(t5));
CHECK(t2 == nctab_prev(t5)); CHECK(t2 == nctab_prev(t5));
// second // second
auto t6 = nctabbed_add(nt, t1, nullptr, tabbedcb, "tab6", nullptr); auto t6 = nctabbed_add(nt, t1, nullptr, tabbedcb, "tab6", nullptr);
CHECK(nullptr != t6); REQUIRE(nullptr != t6);
CHECK(t3 == nctab_next(t6)); CHECK(t3 == nctab_next(t6));
CHECK(t1 == nctab_prev(t6)); CHECK(t1 == nctab_prev(t6));
nctabbed_destroy(nt); nctabbed_destroy(nt);

Loading…
Cancel
Save