From a84d8dc3860c324f6dc622e8eb9f983acd7f692c Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Tue, 26 Dec 2017 18:05:10 +0000 Subject: Add basic outline for spanish patience testing --- src/test/main_test.cpp | 19 ------------------- src/test/spanish_patience_test.cpp | 11 +++++++++++ src/test/test_helper.cpp | 9 +++++++++ src/test/test_helper.h | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 19 deletions(-) delete mode 100644 src/test/main_test.cpp create mode 100644 src/test/spanish_patience_test.cpp create mode 100644 src/test/test_helper.cpp create mode 100644 src/test/test_helper.h (limited to 'src/test') diff --git a/src/test/main_test.cpp b/src/test/main_test.cpp deleted file mode 100644 index 3f2081f..0000000 --- a/src/test/main_test.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -// Created by thecharlesblake on 10/4/17. -// - -#include - -const int actualValTrue = 4; -const int actualValFalse = 8; -const int expectVal = 4; - -namespace { - TEST(StrCompare, CStrEqual) { - EXPECT_EQ(expectVal, actualValTrue); - } - - TEST(StrCompare, CStrNotEqual) { - EXPECT_NE(expectVal, actualValFalse); - } -} diff --git a/src/test/spanish_patience_test.cpp b/src/test/spanish_patience_test.cpp new file mode 100644 index 0000000..f75fc8b --- /dev/null +++ b/src/test/spanish_patience_test.cpp @@ -0,0 +1,11 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include + +#include "test_helper.h" + +TEST(SpanishPatience, SPTestName) { + EXPECT_TRUE(test_helper::is_solvable("i", "simple-spanish-patience")); +} diff --git a/src/test/test_helper.cpp b/src/test/test_helper.cpp new file mode 100644 index 0000000..5e08bc3 --- /dev/null +++ b/src/test/test_helper.cpp @@ -0,0 +1,9 @@ +// +// Created by thecharlesblake on 12/26/17. +// + +#include "test_helper.h" + +bool test_helper::is_solvable(std::string, std::string) { + return false; +} diff --git a/src/test/test_helper.h b/src/test/test_helper.h new file mode 100644 index 0000000..38bdfc0 --- /dev/null +++ b/src/test/test_helper.h @@ -0,0 +1,16 @@ +// +// Created by thecharlesblake on 12/26/17. +// + +#ifndef SOLVITAIRE_TEST_HELPER_H +#define SOLVITAIRE_TEST_HELPER_H + +#include + +class test_helper { +public: + static bool is_solvable(std::string, std::string); +}; + + +#endif //SOLVITAIRE_TEST_HELPER_H -- cgit v1.2.1 From f8931f348ef456d9fac78b5cadad280f81dfcfc6 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 27 Dec 2017 00:04:32 +0000 Subject: First sp test working --- src/test/resources/SPTestName.json | 7 +++++++ src/test/spanish_patience_test.cpp | 6 +++++- src/test/test_helper.cpp | 18 ++++++++++++++++-- src/test/test_helper.h | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/SPTestName.json (limited to 'src/test') diff --git a/src/test/resources/SPTestName.json b/src/test/resources/SPTestName.json new file mode 100644 index 0000000..6d1586c --- /dev/null +++ b/src/test/resources/SPTestName.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["2S", "AS", "AD"], + ["2D", "2H", "AH"], + ["2C", "AC"] + ] +} \ No newline at end of file diff --git a/src/test/spanish_patience_test.cpp b/src/test/spanish_patience_test.cpp index f75fc8b..4168193 100644 --- a/src/test/spanish_patience_test.cpp +++ b/src/test/spanish_patience_test.cpp @@ -6,6 +6,10 @@ #include "test_helper.h" +typedef test_helper th; + +const static std::string type = "simple-spanish-patience"; + TEST(SpanishPatience, SPTestName) { - EXPECT_TRUE(test_helper::is_solvable("i", "simple-spanish-patience")); + EXPECT_TRUE(th::is_solvable("SPTestName", type)); } diff --git a/src/test/test_helper.cpp b/src/test/test_helper.cpp index 5e08bc3..2e08829 100644 --- a/src/test/test_helper.cpp +++ b/src/test/test_helper.cpp @@ -2,8 +2,22 @@ // Created by thecharlesblake on 12/26/17. // +#include + #include "test_helper.h" +#include "../main/game/game_state.h" +#include "../main/solver/solver.h" +#include "../main/util/util.h" + +using namespace rapidjson; +using namespace std; + +bool test_helper::is_solvable(const std::string& input_file, const std::string& preset_type) { + const Document in_doc = util::get_file_json("resources/" + input_file + ".json"); + const sol_rules rules = sol_rules::from_preset(preset_type); + + game_state gs(rules, in_doc); + solver sol(gs, rules); -bool test_helper::is_solvable(std::string, std::string) { - return false; + return sol.run() ? true : false; } diff --git a/src/test/test_helper.h b/src/test/test_helper.h index 38bdfc0..5b8e755 100644 --- a/src/test/test_helper.h +++ b/src/test/test_helper.h @@ -9,7 +9,7 @@ class test_helper { public: - static bool is_solvable(std::string, std::string); + static bool is_solvable(const std::string&, const std::string&); }; -- cgit v1.2.1 From 6c4bdf37d6bebe3562df9c9b459e6b7036f21dea Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 27 Dec 2017 00:23:07 +0000 Subject: All basic sp tests complete --- src/test/resources/SPTestName.json | 7 ------- .../resources/spanish_patience/ComplexSolvable.json | 7 +++++++ .../resources/spanish_patience/ComplexUnsolvable.json | 7 +++++++ src/test/resources/spanish_patience/SimpleSolvable.json | 7 +++++++ .../resources/spanish_patience/SimpleUnsolvable.json | 7 +++++++ src/test/spanish_patience_test.cpp | 17 +++++++++++++++-- src/test/test_helper.cpp | 2 +- 7 files changed, 44 insertions(+), 10 deletions(-) delete mode 100644 src/test/resources/SPTestName.json create mode 100644 src/test/resources/spanish_patience/ComplexSolvable.json create mode 100644 src/test/resources/spanish_patience/ComplexUnsolvable.json create mode 100644 src/test/resources/spanish_patience/SimpleSolvable.json create mode 100644 src/test/resources/spanish_patience/SimpleUnsolvable.json (limited to 'src/test') diff --git a/src/test/resources/SPTestName.json b/src/test/resources/SPTestName.json deleted file mode 100644 index 6d1586c..0000000 --- a/src/test/resources/SPTestName.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "tableau piles": [ - ["2S", "AS", "AD"], - ["2D", "2H", "AH"], - ["2C", "AC"] - ] -} \ No newline at end of file diff --git a/src/test/resources/spanish_patience/ComplexSolvable.json b/src/test/resources/spanish_patience/ComplexSolvable.json new file mode 100644 index 0000000..c48ce47 --- /dev/null +++ b/src/test/resources/spanish_patience/ComplexSolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AS", "2S", "AH"], + ["AD", "2D", "2H"], + ["2C", "AC"] + ] +} diff --git a/src/test/resources/spanish_patience/ComplexUnsolvable.json b/src/test/resources/spanish_patience/ComplexUnsolvable.json new file mode 100644 index 0000000..ba9be59 --- /dev/null +++ b/src/test/resources/spanish_patience/ComplexUnsolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AS", "2S", "AH"], + ["AD", "2D", "2H"], + ["AC", "2C"] + ] +} diff --git a/src/test/resources/spanish_patience/SimpleSolvable.json b/src/test/resources/spanish_patience/SimpleSolvable.json new file mode 100644 index 0000000..eacad0e --- /dev/null +++ b/src/test/resources/spanish_patience/SimpleSolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["2S", "AS", "AD"], + ["2D", "2H", "AH"], + ["2C", "AC"] + ] +} diff --git a/src/test/resources/spanish_patience/SimpleUnsolvable.json b/src/test/resources/spanish_patience/SimpleUnsolvable.json new file mode 100644 index 0000000..99a3140 --- /dev/null +++ b/src/test/resources/spanish_patience/SimpleUnsolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AS", "2S", "2D"], + ["AD", "AH", "2H"], + ["AC", "2C"] + ] +} diff --git a/src/test/spanish_patience_test.cpp b/src/test/spanish_patience_test.cpp index 4168193..8973a53 100644 --- a/src/test/spanish_patience_test.cpp +++ b/src/test/spanish_patience_test.cpp @@ -8,8 +8,21 @@ typedef test_helper th; +const static std::string path = "resources/spanish_patience/"; const static std::string type = "simple-spanish-patience"; -TEST(SpanishPatience, SPTestName) { - EXPECT_TRUE(th::is_solvable("SPTestName", type)); +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/src/test/test_helper.cpp b/src/test/test_helper.cpp index 2e08829..9c258a3 100644 --- a/src/test/test_helper.cpp +++ b/src/test/test_helper.cpp @@ -13,7 +13,7 @@ using namespace rapidjson; using namespace std; bool test_helper::is_solvable(const std::string& input_file, const std::string& preset_type) { - const Document in_doc = util::get_file_json("resources/" + input_file + ".json"); + const Document in_doc = util::get_file_json(input_file); const sol_rules rules = sol_rules::from_preset(preset_type); game_state gs(rules, in_doc); -- cgit v1.2.1 From 3759513307f324761b9bf6f4ef20ebeb9c3da98a Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 27 Dec 2017 12:04:33 +0000 Subject: All basic bh tests complete --- src/test/black_hole_test.cpp | 28 ++++++++++++++++++++++ src/test/resources/black_hole/ComplexSolvable.json | 9 +++++++ .../resources/black_hole/ComplexUnsolvable.json | 9 +++++++ src/test/resources/black_hole/SimpleSolvable.json | 9 +++++++ .../resources/black_hole/SimpleUnsolvable.json | 9 +++++++ 5 files changed, 64 insertions(+) create mode 100644 src/test/black_hole_test.cpp create mode 100644 src/test/resources/black_hole/ComplexSolvable.json create mode 100644 src/test/resources/black_hole/ComplexUnsolvable.json create mode 100644 src/test/resources/black_hole/SimpleSolvable.json create mode 100644 src/test/resources/black_hole/SimpleUnsolvable.json (limited to 'src/test') diff --git a/src/test/black_hole_test.cpp b/src/test/black_hole_test.cpp new file mode 100644 index 0000000..89ee50a --- /dev/null +++ b/src/test/black_hole_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include + +#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/src/test/resources/black_hole/ComplexSolvable.json b/src/test/resources/black_hole/ComplexSolvable.json new file mode 100644 index 0000000..8d0249d --- /dev/null +++ b/src/test/resources/black_hole/ComplexSolvable.json @@ -0,0 +1,9 @@ +{ + "tableau piles": [ + ["5D","4D","3D","2D","AD"], + ["5C","4C","3C","2C","4H","5H"], + ["AC","AH","2H","3H"], + ["2S","5S","4S","3S"] + ], + "hole": "AS" +} diff --git a/src/test/resources/black_hole/ComplexUnsolvable.json b/src/test/resources/black_hole/ComplexUnsolvable.json new file mode 100644 index 0000000..89eb08f --- /dev/null +++ b/src/test/resources/black_hole/ComplexUnsolvable.json @@ -0,0 +1,9 @@ +{ + "tableau piles": [ + ["5","3","2","4","A"], + ["5","3","2","4","A"], + ["5","3","3","4","A"], + ["5","2","2","2"] + ], + "hole": "AS" +} diff --git a/src/test/resources/black_hole/SimpleSolvable.json b/src/test/resources/black_hole/SimpleSolvable.json new file mode 100644 index 0000000..3a7be18 --- /dev/null +++ b/src/test/resources/black_hole/SimpleSolvable.json @@ -0,0 +1,9 @@ +{ + "tableau piles": [ + ["AD","2D","3D","4D","5D"], + ["AC","2C","3C","4C","5C"], + ["AH","2H","3H","4H","5H"], + ["2S","3S","4S","5S"] + ], + "hole": "AS" +} diff --git a/src/test/resources/black_hole/SimpleUnsolvable.json b/src/test/resources/black_hole/SimpleUnsolvable.json new file mode 100644 index 0000000..d6a5e7c --- /dev/null +++ b/src/test/resources/black_hole/SimpleUnsolvable.json @@ -0,0 +1,9 @@ +{ + "tableau piles": [ + ["5D","4D","3D","2D","AD"], + ["5C","4C","3C","2C","AC"], + ["5H","4H","3H","2H","AH"], + ["5S","4S","2S","3S"] + ], + "hole": "AS" +} -- cgit v1.2.1 From 588a36c63991d24566d4af6f1b9722186bdcc286 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 27 Dec 2017 23:55:34 +0000 Subject: Added fc tests - currently intract. --- src/test/free_cell_test.cpp | 28 ++++++++++++++++++++++ src/test/resources/free_cell/ComplexSolvable.json | 7 ++++++ .../resources/free_cell/ComplexUnsolvable.json | 7 ++++++ src/test/resources/free_cell/SimpleSolvable.json | 7 ++++++ src/test/resources/free_cell/SimpleUnsolvable.json | 7 ++++++ 5 files changed, 56 insertions(+) create mode 100644 src/test/free_cell_test.cpp create mode 100644 src/test/resources/free_cell/ComplexSolvable.json create mode 100644 src/test/resources/free_cell/ComplexUnsolvable.json create mode 100644 src/test/resources/free_cell/SimpleSolvable.json create mode 100644 src/test/resources/free_cell/SimpleUnsolvable.json (limited to 'src/test') diff --git a/src/test/free_cell_test.cpp b/src/test/free_cell_test.cpp new file mode 100644 index 0000000..507c915 --- /dev/null +++ b/src/test/free_cell_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include + +#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/src/test/resources/free_cell/ComplexSolvable.json b/src/test/resources/free_cell/ComplexSolvable.json new file mode 100644 index 0000000..2c284d9 --- /dev/null +++ b/src/test/resources/free_cell/ComplexSolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AH","AC","2C","3C"], + ["AD","2H","2D","3D"], + ["3H","2S","AS","3S"] + ] +} diff --git a/src/test/resources/free_cell/ComplexUnsolvable.json b/src/test/resources/free_cell/ComplexUnsolvable.json new file mode 100644 index 0000000..279c319 --- /dev/null +++ b/src/test/resources/free_cell/ComplexUnsolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AH","AC","3H","3C"], + ["AD","2H","2D","3D"], + ["2C","2S","AS","3S"] + ] +} diff --git a/src/test/resources/free_cell/SimpleSolvable.json b/src/test/resources/free_cell/SimpleSolvable.json new file mode 100644 index 0000000..2ae2f1a --- /dev/null +++ b/src/test/resources/free_cell/SimpleSolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["3H","2H","AH","AC"], + ["3D","2D","2C","AD"], + ["3S","3C","2S","AS"] + ] +} diff --git a/src/test/resources/free_cell/SimpleUnsolvable.json b/src/test/resources/free_cell/SimpleUnsolvable.json new file mode 100644 index 0000000..f69312d --- /dev/null +++ b/src/test/resources/free_cell/SimpleUnsolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AH","AC","3H","3C"], + ["AD","2C","2D","3D"], + ["AS","2S","2H","3S"] + ] +} -- cgit v1.2.1