Skip to content

Commit

Permalink
add iterator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pit-ray committed Mar 28, 2024
1 parent 90f6bfe commit 6898b9c
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/tray_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,53 @@ TEST_CASE("FluentTray Test: ") {
CHECK(tray.update_with_loop()) ;
CHECK_EQ(tray.status(), TrayStatus::STOPPED) ;
}

SUBCASE("iterator") {
FluentTray tray ;
CHECK(tray.create_tray("test_iterator", "")) ;

CHECK(tray.add_menu("menu1")) ;
CHECK(tray.add_menu("menu2")) ;
CHECK(tray.add_menu("menu3")) ;

std::string label11 ;
CHECK(tray.front().get_label(label11)) ;
CHECK_EQ(label11, "menu1") ;

std::string label12 ;
CHECK(tray.begin()->get_label(label12)) ;
CHECK_EQ(label12, "menu1") ;

std::string label13 ;
CHECK(tray.cbegin()->get_label(label13)) ;
CHECK_EQ(label13, "menu1") ;

std::string label21 ;
CHECK((tray.begin() + 1)->get_label(label21)) ;
CHECK_EQ(label21, "menu2") ;

std::string label22 ;
CHECK((tray.cbegin() + 1)->get_label(label22)) ;
CHECK_EQ(label22, "menu2") ;

std::string label23 ;
CHECK((tray.cend() - 2)->get_label(label23)) ;
CHECK_EQ(label23, "menu2") ;

std::string label31 ;
CHECK(tray.back().get_label(label31)) ;
CHECK_EQ(label31, "menu3") ;

std::string label32 ;
CHECK((tray.cbegin() + 2)->get_label(label32)) ;
CHECK_EQ(label32, "menu3") ;

std::string label33 ;
CHECK((tray.cend() - 1)->get_label(label33)) ;
CHECK_EQ(label33, "menu3") ;

std::string label34 ;
CHECK((tray.end() - 1)->get_label(label34)) ;
CHECK_EQ(label34, "menu3") ;
}
}

0 comments on commit 6898b9c

Please sign in to comment.