aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorthecharlesblake2017-12-27 00:04:32 +0000
committerthecharlesblake2017-12-27 00:04:32 +0000
commitf8931f348ef456d9fac78b5cadad280f81dfcfc6 (patch)
treeb3df3f6bda5dfd0c6e7bfdeefc62a1eacd6295f4 /src/test
parentAdd basic outline for spanish patience testing (diff)
downloadmetasol-f8931f348ef456d9fac78b5cadad280f81dfcfc6.tar.gz
metasol-f8931f348ef456d9fac78b5cadad280f81dfcfc6.zip

First sp test working

Diffstat (limited to 'src/test')
-rw-r--r--src/test/resources/SPTestName.json7
-rw-r--r--src/test/spanish_patience_test.cpp6
-rw-r--r--src/test/test_helper.cpp18
-rw-r--r--src/test/test_helper.h2
4 files changed, 29 insertions, 4 deletions
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 <rapidjson/document.h>
+
#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&);
};