aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/foundations_dominance_test.cpp5
-rw-r--r--src/test/global_cache_test.cpp16
-rw-r--r--src/test/test_helper.cpp97
-rw-r--r--src/test/test_helper.h8
4 files changed, 0 insertions, 126 deletions
diff --git a/src/test/foundations_dominance_test.cpp b/src/test/foundations_dominance_test.cpp
index 48134f5..77a33ff 100644
--- a/src/test/foundations_dominance_test.cpp
+++ b/src/test/foundations_dominance_test.cpp
@@ -26,9 +26,4 @@ TEST(FoundationsDominance, AnySuit) {
test_helper::run_foundations_dominance_test(pol::ANY_SUIT, {
"AC","2C","AH","2H","AS","2S","AD","3C","3H","3S","2D","4C","4H",
"4S","3D","4D"});
-}
-
-TEST(FoundationsDominance, NoSolutionChange) {
- test_helper::optimisation_validity_test(
- test_helper::optimisation::AUTO_FOUNDATION_MOVES);
} \ No newline at end of file
diff --git a/src/test/global_cache_test.cpp b/src/test/global_cache_test.cpp
index 70a6b33..780146b 100644
--- a/src/test/global_cache_test.cpp
+++ b/src/test/global_cache_test.cpp
@@ -10,22 +10,6 @@
typedef sol_rules::build_policy pol;
-TEST(GlobalCache, BuildSameSuit) {
- test_helper::run_card_cache_test(pol::SAME_SUIT, false, false);
-}
-
-TEST(GlobalCache, BuildRedBlack) {
- test_helper::run_card_cache_test(pol::RED_BLACK, false, true);
-}
-
-TEST(GlobalCache, BuildAny) {
- test_helper::run_card_cache_test(pol::ANY_SUIT, true, true);
-}
-
-TEST(GlobalCache, BuildNone) {
- test_helper::run_card_cache_test(pol::NO_BUILD, true, true);
-}
-
TEST(GlobalCache, CommutativeTableauPiles) {
sol_rules rules;
rules.tableau_pile_count = 3;
diff --git a/src/test/test_helper.cpp b/src/test/test_helper.cpp
index 37fc32d..da618d8 100644
--- a/src/test/test_helper.cpp
+++ b/src/test/test_helper.cpp
@@ -26,59 +26,6 @@ bool test_helper::is_solvable(const std::string& input_file, const std::string&
return sol.run();
}
-void test_helper::run_card_cache_test(sol_rules::build_policy bp,
- bool assert_dif_col,
- bool assert_same_col) {
- sol_rules rules;
- rules.tableau_pile_count = 1;
- rules.build_pol = bp;
-
- for (uint8_t suit_idx = 0; suit_idx < 4; suit_idx++) {
- for (card::rank_t rank = 1; rank <= 13; rank++) {
- // c2 is the same as c_ but with a different suit
- const card c = card(suit_idx, rank);
- const card c_dif_col = card(uint8_t((suit_idx + 1) % 4), rank);
- const card c_same_col = card(uint8_t((suit_idx + 2) % 4), rank);
- const card c_dif_rank = card(suit_idx, card::rank_t((rank % 13) + 1));
-
- const game_state s = game_state(rules, initializer_list<pile>{{c}});
- const game_state s_dif_suit(rules, initializer_list<pile>{{c_dif_col}});
- const game_state s_same_col(rules, initializer_list<pile>{{c_same_col}});
- const game_state s_dif_rank(rules, initializer_list<pile>{{c_dif_rank}});
-
- global_cache cache(s);
-
- cache.insert(s);
-
- ASSERT_TRUE(cache.contains(s)) << "Contains self";
-
- ASSERT_(assert_dif_col, hasher(s)(cached_game_state(s))
- == hasher(s)(cached_game_state(s_dif_suit)))
- << "Insert: " << c.to_string()
- << ", Comp: " << c_dif_col.to_string();
- ASSERT_(assert_dif_col, cache.contains(s_dif_suit))
- << "Insert: " << c.to_string()
- << ", Comp: " << c_dif_col.to_string();
-
- ASSERT_(assert_same_col, hasher(s)(cached_game_state(s))
- == hasher(s)(cached_game_state(s_same_col)))
- << "Insert: " << c.to_string()
- << ", Comp: " << c_same_col.to_string();
- ASSERT_(assert_same_col, cache.contains(s_same_col))
- << "Insert: " << c.to_string()
- << ", Comp: " << c_same_col.to_string();
-
- ASSERT_FALSE(hasher(s)(cached_game_state(s))
- == hasher(s)(cached_game_state(s_dif_rank)))
- << "Insert: " << c.to_string()
- << ", Comp: " << c_dif_rank.to_string();
- ASSERT_FALSE(cache.contains(s_dif_rank))
- << "Insert: " << c.to_string()
- << ", Comp: " << c_dif_rank.to_string();
- }
- }
-}
-
void test_helper::run_foundations_dominance_test(sol_rules::build_policy policy,
std::vector<card> cards) {
sol_rules rules = rules_parser::from_preset("simple-free-cell");
@@ -110,47 +57,3 @@ void test_helper::run_foundations_dominance_test(sol_rules::build_policy policy,
}
ASSERT_TRUE(n->children.empty());
}
-
-void test_helper::optimisation_validity_test(optimisation op) {
- for (string preset : {
- "simple-alpha-star",
- "simple-bakers-dozen",
- "simple-black-hole",
- "simple-canfield",
- "simple-flower-garden",
- "simple-fortunes-favor",
- "simple-free-cell",
- "simple-somerset",
- "simple-spanish-patience",
- "simple-spider"
- }) {
- vector<bool> solutions_op, solutions_no_op;
-
- switch (op) {
- case optimisation::AUTO_FOUNDATION_MOVES:
-#define NO_AUTO_FOUNDATIONS
- solutions_no_op = run_many_games(preset);
-#undef NO_AUTO_FOUNDATIONS
- solutions_op = run_many_games(preset);
- break;
- }
-
- ASSERT_TRUE(solutions_op == solutions_no_op) << preset;
- }
-}
-
-std::vector<bool> test_helper::run_many_games(std::string preset) {
-#ifdef NDEBUG
- const int run_count = 2000;
-#else
- const int run_count = 5;
-#endif
-
- vector<bool> solutions;
- for (int seed = 0; seed < run_count; seed++) {
- solver sol(game_state(rules_parser::from_preset(preset), seed));
- solutions.push_back(sol.run());
- }
-
- return solutions;
-}
diff --git a/src/test/test_helper.h b/src/test/test_helper.h
index 24acb5f..b0199af 100644
--- a/src/test/test_helper.h
+++ b/src/test/test_helper.h
@@ -12,19 +12,11 @@
class test_helper {
public:
- enum class optimisation {
- AUTO_FOUNDATION_MOVES
- };
-
static bool is_solvable(const std::string&, const std::string&);
static void run_card_cache_test(sol_rules::build_policy, bool, bool);
static void run_foundations_dominance_test(sol_rules::build_policy policy,
std::vector<card> cards);
-
- static void optimisation_validity_test(optimisation);
-
- static std::vector<bool> run_many_games(std::string);
};