Created
February 7, 2011 09:55
-
-
Save grk/814194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Work/uni/padp/lists(master*) $ ./test | |
[==========] Running 5 tests from 1 test case. | |
[----------] Global test environment set-up. | |
[----------] 5 tests from linked_list_test | |
[ RUN ] linked_list_test.is_empty_initially | |
[ OK ] linked_list_test.is_empty_initially (0 ms) | |
[ RUN ] linked_list_test.add_element | |
[ OK ] linked_list_test.add_element (0 ms) | |
[ RUN ] linked_list_test.add_exisiting_element | |
[ OK ] linked_list_test.add_exisiting_element (0 ms) | |
[ RUN ] linked_list_test.remove_element | |
[ OK ] linked_list_test.remove_element (0 ms) | |
[ RUN ] linked_list_test.remove_nonexistant_element | |
[ OK ] linked_list_test.remove_nonexistant_element (0 ms) | |
[----------] 5 tests from linked_list_test (0 ms total) | |
[----------] Global test environment tear-down | |
[==========] 5 tests from 1 test case ran. (10 ms total) | |
[ PASSED ] 5 tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <gtest/gtest.h> | |
#include "linked_list.hpp" | |
namespace { | |
class linked_list_test : public ::testing::Test | |
{ | |
protected: | |
linked_list_test() | |
{ | |
int_list.clear(); | |
} | |
linked_list<int> int_list; | |
}; | |
TEST_F(linked_list_test, is_empty_initially) | |
{ | |
EXPECT_EQ(0, int_list.size()); | |
} | |
TEST_F(linked_list_test, add_element) | |
{ | |
EXPECT_EQ(true, int_list.add(1)); | |
EXPECT_EQ(1, int_list.size()); | |
} | |
TEST_F(linked_list_test, add_exisiting_element) | |
{ | |
int_list.add(1); | |
EXPECT_EQ(false, int_list.add(1)); | |
EXPECT_EQ(1, int_list.size()); | |
} | |
TEST_F(linked_list_test, remove_element) | |
{ | |
int_list.add(1); | |
int_list.add(2); | |
int_list.add(3); | |
EXPECT_EQ(true, int_list.remove(2)); | |
EXPECT_EQ(2, int_list.size()); | |
} | |
TEST_F(linked_list_test, remove_nonexistant_element) | |
{ | |
int_list.add(1); | |
EXPECT_EQ(false, int_list.remove(2)); | |
EXPECT_EQ(1, int_list.size()); | |
} | |
} // namespace | |
int main(int argc, char** argv) | |
{ | |
::testing::InitGoogleTest(&argc, argv); | |
return RUN_ALL_TESTS(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment