diff options
| author | Tom Harley | 2019-01-27 15:37:06 +0000 |
|---|---|---|
| committer | Tom Harley | 2019-01-27 15:37:06 +0000 |
| commit | a996283af7c21baaff0e114d58c34db820902c6f (patch) | |
| tree | 2fe5b6f7a800d4a7b8a65ee345f8c98aa138e36b /solvitaire/src/test/unit_tests/pile_test.cpp | |
| parent | Split code into 3 files (diff) | |
| download | metasol-a996283af7c21baaff0e114d58c34db820902c6f.tar.gz metasol-a996283af7c21baaff0e114d58c34db820902c6f.zip | |
Reorganise repo
All solvitaire content has been shoved into a subdirectory to tidy up the root of the project. This also means solvitaire is treated similarly to other dependencies of the project, and allows other dependencies to be added easily.
There’s also a lot of other work done here, such as usign a thread pool library to manage the running of the voters.
Diffstat (limited to 'solvitaire/src/test/unit_tests/pile_test.cpp')
| -rw-r--r-- | solvitaire/src/test/unit_tests/pile_test.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/solvitaire/src/test/unit_tests/pile_test.cpp b/solvitaire/src/test/unit_tests/pile_test.cpp new file mode 100644 index 0000000..a5aeb66 --- /dev/null +++ b/solvitaire/src/test/unit_tests/pile_test.cpp @@ -0,0 +1,87 @@ +// +// Created by thecharlesblake on 1/11/18. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" +#include "../../main/game/pile.h" + +TEST(Pile, Size) { + pile p = {}; + ASSERT_EQ(0, p.size()); + + p = {"AS"}; + ASSERT_EQ(1, p.size()); + + p = {"AS", "KC", "4H"}; + ASSERT_EQ(3, p.size()); +} + +TEST(Pile, TopCard) { + pile p = {"AS"}; + ASSERT_EQ(card("AS"), p.top_card()); + + p = {"AS", "KC", "4H"}; + ASSERT_NE(card("AS"), p.top_card()); + ASSERT_EQ(card("4H"), p.top_card()); +} + +TEST(Pile, Index) { + pile p = {"AS"}; + ASSERT_EQ(card("AS"), p[0]); + + p = {"AS", "KC", "4H"}; + ASSERT_EQ(card("AS"), p[2]); + ASSERT_EQ(card("KC"), p[1]); + ASSERT_EQ(card("4H"), p[0]); +} + +TEST(Pile, Place) { + pile t1 = {}; + pile t2 = {"AS"}; + pile t3 = {"AS", "KC", "4H"}; + + pile p = {}; + ASSERT_EQ(p, t1); + + p.place("AS"); + ASSERT_NE(p, t1); + ASSERT_EQ(p, t2); + + p.place("KC"); + p.place("4H"); + ASSERT_NE(p, t2); + ASSERT_EQ(p, t3); +} + +TEST(Pile, Take) { + pile t1 = {}; + pile t2 = {"AS"}; + pile t3 = {"AS", "KC", "4H"}; + + pile p = {"AS", "KC", "4H"}; + ASSERT_EQ(p, t3); + + p.take(); + p.take(); + ASSERT_NE(p, t3); + ASSERT_EQ(p, t2); + + p.take(); + ASSERT_NE(p, t2); + ASSERT_EQ(p, t1); +} + +TEST(Pile, CompOperators) { + pile p1 = {"3S"}; + pile p2 = {"AS", "AD", "AC"}; + pile p3 = {"2S", "2D", "2C"}; + pile p4 = {"AS", "AD", "AC", "AH"}; + + ASSERT_LT(p1, p2); + ASSERT_LT(p2, p3); + ASSERT_LT(p3, p4); + ASSERT_LT(p1, p4); + ASSERT_EQ(p4, p4); +} |
