diff options
Diffstat (limited to 'solvitaire/src/test/integration_tests')
13 files changed, 477 insertions, 0 deletions
diff --git a/solvitaire/src/test/integration_tests/accordion_test.cpp b/solvitaire/src/test/integration_tests/accordion_test.cpp new file mode 100644 index 0000000..bd27dec --- /dev/null +++ b/solvitaire/src/test/integration_tests/accordion_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/accordion/"; +const static std::string type = "simple-accordion"; + +TEST(Accordion, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(Accordion, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(Accordion, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(Accordion, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/alpha_star_test.cpp b/solvitaire/src/test/integration_tests/alpha_star_test.cpp new file mode 100644 index 0000000..c3b23fe --- /dev/null +++ b/solvitaire/src/test/integration_tests/alpha_star_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/alpha_star/"; +const static std::string type = "simple-alpha-star"; + +TEST(AlphaStar, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(AlphaStar, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(AlphaStar, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(AlphaStar, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/bakers_dozen_test.cpp b/solvitaire/src/test/integration_tests/bakers_dozen_test.cpp new file mode 100644 index 0000000..f3d4763 --- /dev/null +++ b/solvitaire/src/test/integration_tests/bakers_dozen_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/bakers_dozen/"; +const static std::string type = "simple-bakers-dozen"; + +TEST(BakersDozen, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(BakersDozen, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(BakersDozen, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(BakersDozen, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/black_hole_test.cpp b/solvitaire/src/test/integration_tests/black_hole_test.cpp new file mode 100644 index 0000000..a0f6707 --- /dev/null +++ b/solvitaire/src/test/integration_tests/black_hole_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/black_hole/"; +const static std::string type = "simple-black-hole"; + +TEST(BlackHole, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(BlackHole, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(BlackHole, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(BlackHole, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/canfield_test.cpp b/solvitaire/src/test/integration_tests/canfield_test.cpp new file mode 100644 index 0000000..0cb14b2 --- /dev/null +++ b/solvitaire/src/test/integration_tests/canfield_test.cpp @@ -0,0 +1,139 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" +#include "../../main/input-output/input/json-parsing/rules_parser.h" +#include "../../main/game/search-state/game_state.h" + +using std::vector; + +typedef test_helper th; +typedef game_state::streamliner_options so; +typedef std::initializer_list<std::initializer_list<std::string>> string_il; + +const static std::string path = "resources/canfield/"; +const static std::string type = "simple-canfield"; + +TEST(Canfield, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(Canfield, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(Canfield, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(Canfield, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} + +TEST(Canfield, FoundationSingleCard) { + sol_rules sr = rules_parser::from_preset("canfield"); + game_state gs(sr, 0, so::NONE); + + ASSERT_EQ(1, test_helper::cards_in_founds(gs)); +} + +TEST(Canfield, FoundationWraps) { + sol_rules sr = rules_parser::from_preset("simple-canfield"); + + game_state gs(sr, string_il{ + {"3C"},{},{},{}, // Foundations + {},{}, // Stock-waste + {}, // Reserve + {"AC"},{},{} // Tableau piles + }); + + vector<move> actual_moves = gs.get_legal_moves(); + vector<move> exp_moves = { + move(move::mtype::regular, 7, 0, 1) + }; + + ASSERT_TRUE(test_helper::moves_eq(exp_moves, actual_moves)) << actual_moves; +} + +TEST(Canfield, MoveWholePile) { + sol_rules sr = rules_parser::from_preset("simple-canfield"); + + game_state gs(sr, string_il{ + {"AC"},{},{},{}, // Foundations + {},{}, // Stock-waste + {}, // Reserve + {"2C","AH"},{"3H"},{"3C","2D"} // Tableau piles + }); + + vector<move> actual_moves = gs.get_legal_moves(); + vector<move> exp_moves = { + move(move::mtype::built_group, 7, 8, 2), + move(move::mtype::regular, 7, 1, 1), + }; + + ASSERT_TRUE(test_helper::moves_eq(exp_moves, actual_moves)) << actual_moves; +} + +TEST(Canfield, MoveWholePileNotSpace) { + sol_rules sr = rules_parser::from_preset("simple-canfield"); + + game_state gs(sr, string_il{ + {"3C"},{},{},{}, // Foundations + {},{}, // Stock-waste + {}, // Reserve + {"2H","3S","AH"},{},{"2D"} // Tableau piles + }); + + vector<move> actual_moves = gs.get_legal_moves(); + vector<move> exp_moves = {}; + + ASSERT_TRUE(test_helper::moves_eq(exp_moves, actual_moves)) << actual_moves; +} + +TEST(Canfield, AutoReserve) { + sol_rules sr = rules_parser::from_preset("simple-canfield"); + + game_state gs(sr, string_il{ + {"2C"},{},{},{}, // Foundations + {"3D","2D"},{}, // Stock-waste + {"3H"}, // Reserve + {"2H","3S","AH"},{},{"AC"} // Tableau piles + }); + + vector<move> actual_moves = gs.get_legal_moves(); + vector<move> exp_moves = {}; + + ASSERT_TRUE(test_helper::moves_eq(exp_moves, actual_moves)) << actual_moves; + + boost::optional<move> actual_dom_move = gs.get_dominance_move(); + boost::optional<move> exp_dom_move = move(move::mtype::dominance, 6, 8, 1); + + ASSERT_EQ(exp_dom_move, actual_dom_move) << *actual_dom_move; +} + +TEST(Canfield, AutoReserveThenWaste) { + sol_rules sr = rules_parser::from_preset("simple-canfield"); + + game_state gs(sr, string_il{ + {"3C"},{},{},{}, // Foundations + {"2D"},{"2S"}, // Stock-waste + {}, // Reserve + {"2H","3S","AH"},{},{"AD"} // Tableau piles + }); + + vector<move> actual_moves = gs.get_legal_moves(); + vector<move> exp_moves = { + move(move::mtype::stock_k_plus, 4, 8, 0), + move(move::mtype::stock_k_plus, 4, 8, 1) + }; + + ASSERT_TRUE(test_helper::moves_eq(exp_moves, actual_moves)) << actual_moves; + + boost::optional<move> actual_dom_move = gs.get_dominance_move(); + boost::optional<move> exp_dom_move = boost::none; + + ASSERT_EQ(exp_dom_move, actual_dom_move) << *actual_dom_move; +} diff --git a/solvitaire/src/test/integration_tests/flower_garden_test.cpp b/solvitaire/src/test/integration_tests/flower_garden_test.cpp new file mode 100644 index 0000000..641ccc0 --- /dev/null +++ b/solvitaire/src/test/integration_tests/flower_garden_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/flower_garden/"; +const static std::string type = "simple-flower-garden"; + +TEST(FlowerGarden, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(FlowerGarden, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(FlowerGarden, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(FlowerGarden, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/fortunes_favor_test.cpp b/solvitaire/src/test/integration_tests/fortunes_favor_test.cpp new file mode 100644 index 0000000..5511f9e --- /dev/null +++ b/solvitaire/src/test/integration_tests/fortunes_favor_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/fortunes_favor/"; +const static std::string type = "simple-fortunes-favor"; + +TEST(FortunesFavor, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(FortunesFavor, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(FortunesFavor, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(FortunesFavor, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/free_cell_test.cpp b/solvitaire/src/test/integration_tests/free_cell_test.cpp new file mode 100644 index 0000000..659d86b --- /dev/null +++ b/solvitaire/src/test/integration_tests/free_cell_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/free_cell/"; +const static std::string type = "simple-free-cell"; + +TEST(FreeCell, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(FreeCell, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(FreeCell, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(FreeCell, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/gaps_test.cpp b/solvitaire/src/test/integration_tests/gaps_test.cpp new file mode 100644 index 0000000..f7d0ebe --- /dev/null +++ b/solvitaire/src/test/integration_tests/gaps_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/gaps/"; +const static std::string type = "simple-gaps"; + +TEST(Gaps, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(Gaps, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(Gaps, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(Gaps, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/klondike_test.cpp b/solvitaire/src/test/integration_tests/klondike_test.cpp new file mode 100644 index 0000000..d449495 --- /dev/null +++ b/solvitaire/src/test/integration_tests/klondike_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/klondike/"; +const static std::string type = "simple-klondike"; + +TEST(Klondike, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(Klondike, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(Klondike, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(Klondike, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/somerset_test.cpp b/solvitaire/src/test/integration_tests/somerset_test.cpp new file mode 100644 index 0000000..fce8e8c --- /dev/null +++ b/solvitaire/src/test/integration_tests/somerset_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/somerset/"; +const static std::string type = "simple-somerset"; + +TEST(Somerset, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(Somerset, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(Somerset, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(Somerset, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/spanish_patience_test.cpp b/solvitaire/src/test/integration_tests/spanish_patience_test.cpp new file mode 100644 index 0000000..da32fd5 --- /dev/null +++ b/solvitaire/src/test/integration_tests/spanish_patience_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/spanish_patience/"; +const static std::string type = "simple-spanish-patience"; + +TEST(SpanishPatience, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(SpanishPatience, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(SpanishPatience, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(SpanishPatience, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/solvitaire/src/test/integration_tests/spider_test.cpp b/solvitaire/src/test/integration_tests/spider_test.cpp new file mode 100644 index 0000000..50f16fe --- /dev/null +++ b/solvitaire/src/test/integration_tests/spider_test.cpp @@ -0,0 +1,30 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include <gtest/gtest.h> + +#include "../test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/spider/"; +const static std::string type = "simple-spider"; + +TEST(Spider, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(Spider, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(Spider, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +/* Taking too long so removed, at least for now +TEST(Spider, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} +*/ |
