aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorCharlie Blake2018-07-24 12:00:04 +0100
committerCharlie Blake2018-07-24 12:00:04 +0100
commit2acab3e51cabd8ba80738b1faf791980d2abf724 (patch)
treecb3841d736ff353c5d8aea6a4faf81861ef83f5c /src/test
parentSmall bug fixes inc found. base card & whole piles (diff)
downloadmetasol-2acab3e51cabd8ba80738b1faf791980d2abf724.tar.gz
metasol-2acab3e51cabd8ba80738b1faf791980d2abf724.zip

Fix canfield to pass all unit tests

Diffstat (limited to 'src/test')
-rw-r--r--src/test/integration_tests/canfield_test.cpp26
-rw-r--r--src/test/resources/canfield/ComplexSolvable.json10
-rw-r--r--src/test/resources/canfield/ComplexUnsolvable.json12
-rw-r--r--src/test/resources/canfield/SimpleSolvable.json4
-rw-r--r--src/test/resources/canfield/SimpleUnsolvable.json10
5 files changed, 35 insertions, 27 deletions
diff --git a/src/test/integration_tests/canfield_test.cpp b/src/test/integration_tests/canfield_test.cpp
index cdb6d98..006f4fb 100644
--- a/src/test/integration_tests/canfield_test.cpp
+++ b/src/test/integration_tests/canfield_test.cpp
@@ -97,18 +97,21 @@ TEST(Canfield, AutoReserve) {
sol_rules sr = rules_parser::from_preset("simple-canfield");
game_state gs(sr, string_il{
- {"3C"},{},{},{}, // Foundations
- {"3D"},{"2D"}, // Stock-waste
+ {"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 = {
- move(move::mtype::regular, 6, 8, 1)
- };
+ 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) {
@@ -116,16 +119,21 @@ TEST(Canfield, AutoReserveThenWaste) {
game_state gs(sr, string_il{
{"3C"},{},{},{}, // Foundations
- {"3D"},{"3H"}, // Stock-waste
+ {"2D"},{"2S"}, // Stock-waste
{}, // Reserve
- {"2H","3S","AH"},{},{"AC"} // Tableau piles
+ {"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, 1),
- move(move::mtype::stock_k_plus, 4, 8, 2),
+ 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/src/test/resources/canfield/ComplexSolvable.json b/src/test/resources/canfield/ComplexSolvable.json
index 7abae7a..2a4c252 100644
--- a/src/test/resources/canfield/ComplexSolvable.json
+++ b/src/test/resources/canfield/ComplexSolvable.json
@@ -1,10 +1,10 @@
{
"foundations": ["2C"],
"tableau piles": [
- ["AS"],
- ["AC"],
- ["3D"]
+ ["3D"],
+ ["3H"],
+ ["3S"]
],
- "stock": ["2H","3S"],
- "reserve": ["AH","2S","3H","AD","3C","2D"]
+ "reserve": ["AC","2S","3C"],
+ "stock": ["AH","2H","AD","AS","2D"]
} \ No newline at end of file
diff --git a/src/test/resources/canfield/ComplexUnsolvable.json b/src/test/resources/canfield/ComplexUnsolvable.json
index 3869722..297d06b 100644
--- a/src/test/resources/canfield/ComplexUnsolvable.json
+++ b/src/test/resources/canfield/ComplexUnsolvable.json
@@ -1,10 +1,10 @@
{
- "foundations": ["2S","2C"],
+ "foundations": ["2C"],
"tableau piles": [
- ["AS"],
- ["AC"],
- ["3D"]
+ ["AS","3D"],
+ ["AC","3H"],
+ ["3S"]
],
- "stock": ["AH"],
- "reserve": ["3H","2H","3S","AD","3C","2D"]
+ "reserve": ["AH","2S","3C"],
+ "stock": ["AD","2H","2D"]
} \ No newline at end of file
diff --git a/src/test/resources/canfield/SimpleSolvable.json b/src/test/resources/canfield/SimpleSolvable.json
index 450f5bd..3353b5c 100644
--- a/src/test/resources/canfield/SimpleSolvable.json
+++ b/src/test/resources/canfield/SimpleSolvable.json
@@ -5,6 +5,6 @@
["AC"],
["3D"]
],
- "stock": ["AH","3S"],
- "reserve": ["2H","AS","3H","2D","3C","AD"]
+ "reserve": ["AH","3S"],
+ "stock": ["2H","AS","3H","2D","3C","AD"]
} \ No newline at end of file
diff --git a/src/test/resources/canfield/SimpleUnsolvable.json b/src/test/resources/canfield/SimpleUnsolvable.json
index aefa7b8..440c358 100644
--- a/src/test/resources/canfield/SimpleUnsolvable.json
+++ b/src/test/resources/canfield/SimpleUnsolvable.json
@@ -1,10 +1,10 @@
{
"foundations": ["2C"],
"tableau piles": [
- ["AS"],
- ["AC"],
- ["AD"]
+ ["3D"],
+ ["3H"],
+ ["3S"]
],
- "stock": ["2S","3D"],
- "reserve": ["3H","2H","AH","3S","3C","2D"]
+ "reserve": ["2S","AS"],
+ "stock": ["AC","2H","3C","AH","AD","2D"]
} \ No newline at end of file