aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_helper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_helper.cpp')
-rw-r--r--src/test/test_helper.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/test/test_helper.cpp b/src/test/test_helper.cpp
index 6f2a68d..18b36eb 100644
--- a/src/test/test_helper.cpp
+++ b/src/test/test_helper.cpp
@@ -14,7 +14,9 @@
#define ASSERT_(t_f, statement) ASSERT_TRUE((statement) == (t_f))
using namespace rapidjson;
-using namespace std;
+using std::initializer_list;
+using std::vector;
+using std::ostream;
bool test_helper::is_solvable(const std::string& input_file, const std::string& preset_type) {
const Document in_doc = json_helper::get_file_json(input_file);
@@ -57,3 +59,39 @@ void test_helper::run_foundations_dominance_test(sol_rules::build_policy policy,
}
ASSERT_TRUE(n->children.empty());
}
+
+void test_helper::run_built_group_test(sol_rules sr,
+ initializer_list<pile> piles,
+ vector<move> exp_moves) {
+ game_state gs(sr, piles);
+ vector<move> actual_moves = gs.get_legal_moves();
+
+ ASSERT_TRUE(moves_eq(exp_moves, actual_moves)) << actual_moves;
+}
+
+bool test_helper::moves_eq(vector<move>& exp_moves, vector<move>& actual_moves) {
+ if (exp_moves.size() != actual_moves.size()) return false;
+
+ for (move m : actual_moves) {
+ auto it = find(begin(exp_moves), end(exp_moves), m);
+ bool found = it != end(exp_moves);
+
+ if (found) exp_moves.erase(it);
+ else return false;
+ }
+
+ return true;
+}
+ostream& operator <<(ostream& os, const move& m) {
+ return os << "move:(" << int(m.from)
+ << "," << int(m.to)
+ << "," << int(m.count)
+ << ")";
+}
+
+ostream& operator <<(ostream& os, const vector<move>& moves) {
+ for (const move m : moves) {
+ os << m << ",\n";
+ }
+ return os;
+}