aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthecharlesblake2018-01-09 08:51:43 +0000
committerthecharlesblake2018-01-09 08:51:43 +0000
commit2a05e7357744331b7a0c316a72c01508f0199d6a (patch)
tree340ab477450d63b1ca24363c8755fec71a634665
parentAdd json rules for spider (diff)
downloadmetasol-2a05e7357744331b7a0c316a72c01508f0199d6a.tar.gz
metasol-2a05e7357744331b7a0c316a72c01508f0199d6a.zip

Add unit tests for spider

-rw-r--r--CMakeLists.txt3
-rw-r--r--src/test/resources/spider/ComplexSolvable.json13
-rw-r--r--src/test/resources/spider/ComplexUnsolvable.json13
-rw-r--r--src/test/resources/spider/SimpleSolvable.json14
-rw-r--r--src/test/resources/spider/SimpleUnsolvable.json13
-rw-r--r--src/test/spider_test.cpp28
6 files changed, 83 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd279c9..39cd7f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,8 @@ set(sources_test src/test/test_helper.cpp
src/test/flower_garden_test.cpp
src/test/canfield_test.cpp
src/test/somerset_test.cpp
- src/test/alpha_star_test.cpp)
+ src/test/alpha_star_test.cpp
+ src/test/spider_test.cpp)
###############################################################################
## Rapid JSON setup ###########################################################
diff --git a/src/test/resources/spider/ComplexSolvable.json b/src/test/resources/spider/ComplexSolvable.json
new file mode 100644
index 0000000..3591805
--- /dev/null
+++ b/src/test/resources/spider/ComplexSolvable.json
@@ -0,0 +1,13 @@
+{
+ "tableau piles": [
+ ["2D","AD","3D"],
+ ["AC","2C","3C"],
+ ["AS","2S","3S"],
+ ["AH","2H","3H"]
+ ],
+ "stock": [
+ "2C","2D","2H","2S",
+ "AC","AD","AH","AS",
+ "3C","3D","3H","3S"
+ ]
+}
diff --git a/src/test/resources/spider/ComplexUnsolvable.json b/src/test/resources/spider/ComplexUnsolvable.json
new file mode 100644
index 0000000..8fce03d
--- /dev/null
+++ b/src/test/resources/spider/ComplexUnsolvable.json
@@ -0,0 +1,13 @@
+{
+ "tableau piles": [
+ ["2D","AD","3D"],
+ ["AC","AC","3C"],
+ ["AS","AS","3S"],
+ ["AH","AH","3H"]
+ ],
+ "stock": [
+ "2C","2D","2H","2S",
+ "AC","2D","2H","2S",
+ "3C","3D","3H","3S"
+ ]
+}
diff --git a/src/test/resources/spider/SimpleSolvable.json b/src/test/resources/spider/SimpleSolvable.json
new file mode 100644
index 0000000..f0b9b00
--- /dev/null
+++ b/src/test/resources/spider/SimpleSolvable.json
@@ -0,0 +1,14 @@
+{
+ "tableau piles": [
+ ["3C","2C","AC"],
+ ["3D","2D","AD"],
+ ["3H","2H","AH"],
+ ["3S","2S","AS"]
+ ],
+ "stock": [
+ "3C","2C","AC",
+ "3D","2D","AD",
+ "3H","2H","AH",
+ "3S","2S","AS"
+ ]
+}
diff --git a/src/test/resources/spider/SimpleUnsolvable.json b/src/test/resources/spider/SimpleUnsolvable.json
new file mode 100644
index 0000000..d11a6dd
--- /dev/null
+++ b/src/test/resources/spider/SimpleUnsolvable.json
@@ -0,0 +1,13 @@
+{
+ "tableau piles": [
+ ["AC","AC","2C"],
+ ["AD","AD","2D"],
+ ["AH","AH","2H"],
+ ["AS","AS","2S"]
+ ],
+ "stock": [
+ "3C","3D","3H","3S",
+ "2C","2D","2H","2S",
+ "3C","3D","3H","3S"
+ ]
+}
diff --git a/src/test/spider_test.cpp b/src/test/spider_test.cpp
new file mode 100644
index 0000000..0e21f86
--- /dev/null
+++ b/src/test/spider_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/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));
+}
+
+TEST(Spider, ComplexUnsolvable) {
+ EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type));
+}