Skip to content

Commit

Permalink
Some more test cases for table header
Browse files Browse the repository at this point in the history
Increase table header coverage up to approx 100%
  • Loading branch information
spirosmaggioros committed Aug 15, 2024
1 parent e94489a commit 7b5cf17
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/extra/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ TEST_CASE("Testing pop_front function for table class") {
REQUIRE(t[0] == 50);
t.pop_front();
REQUIRE(t.size() == 0);
t.pop_front();
REQUIRE(t.size() == 0);
}

TEST_CASE("Testing pop_back fucntion for table class") {
Expand All @@ -70,6 +72,8 @@ TEST_CASE("Testing pop_back fucntion for table class") {
REQUIRE(t[t.size() - 1] == 10);
t.pop_back();
REQUIRE(t.size() == 0);
t.pop_back();
REQUIRE(t.size() == 0);
}

TEST_CASE("Testing iterators for table class") {
Expand All @@ -86,6 +90,9 @@ TEST_CASE("Testing operator << for table class") {
table<int> t;
t.push_back(10, 20, 30, 40, 50);
CHECK_NOTHROW(std::cout << t << '\n');

table<char> tt;
CHECK_NOTHROW(std::cout << tt << '\n');
}

TEST_CASE("Testing operator = for table class"){
Expand All @@ -105,3 +112,16 @@ TEST_CASE("Testing copy constructor for table class") {
REQUIRE(v1 == v2);
REQUIRE(t.size() == tt.size());
}

TEST_CASE("Testing [] operator for table class") {
table<int> t;
t.push_back(10, 20, 30, 40, 50);
std::vector<int> v { t.vectorize() };
for(int i = 0; i<t.size(); i++){
REQUIRE(t[i] == v[i]);
}

REQUIRE(t[2] == 30);
REQUIRE(t[4] == 50);
REQUIRE(t[0] == 10);
}

0 comments on commit 7b5cf17

Please sign in to comment.