mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 19:13:25 -08:00
Added tests
This commit is contained in:
parent
e456e4d461
commit
31944076fb
1 changed files with 174 additions and 12 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
#include "libcockatrice/card/database/card_database.h"
|
#include "libcockatrice/card/database/card_database.h"
|
||||||
#include "libcockatrice/card/database/card_database_querier.h"
|
#include "libcockatrice/card/database/card_database_querier.h"
|
||||||
#include "libcockatrice/card/set/card_set.h"
|
#include "libcockatrice/card/set/card_set.h"
|
||||||
|
#include "libcockatrice/filters/filter_tree.h"
|
||||||
#include "test_card_database_path_provider.h"
|
#include "test_card_database_path_provider.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
@ -20,7 +21,6 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
class FilterTreeTest : public ::testing::Test
|
class FilterTreeTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -30,22 +30,185 @@ protected:
|
||||||
new TestCardDatabasePathProvider(), new NoopCardSetPriorityController());
|
new TestCardDatabasePathProvider(), new NoopCardSetPriorityController());
|
||||||
db->loadCardDatabases();
|
db->loadCardDatabases();
|
||||||
|
|
||||||
cat = db->query()->getCardBySimpleName("Cat");
|
language = CardSearchLanguage{};
|
||||||
notDeadAfterAll = db->query()->getCardBySimpleName("Not Dead");
|
|
||||||
|
island = db->query()->getCardBySimpleName("Island");
|
||||||
|
artifact = db->query()->getCardBySimpleName("Artifact");
|
||||||
truth = db->query()->getCardBySimpleName("Truth");
|
truth = db->query()->getCardBySimpleName("Truth");
|
||||||
doctor = db->query()->getCardBySimpleName("Doctor");
|
notDead = db->query()->getCardBySimpleName("Not Dead");
|
||||||
|
wallOfDenial = db->query()->getCardBySimpleName("Wall of Denial");
|
||||||
|
maelstromAngel = db->query()->getCardBySimpleName("Maelstrom Archangel");
|
||||||
}
|
}
|
||||||
// void TearDown() override {}
|
|
||||||
|
|
||||||
CardData cat;
|
CardSearchLanguage language;
|
||||||
CardData notDeadAfterAll;
|
|
||||||
CardData truth;
|
CardData island; // c/u
|
||||||
CardData doctor;
|
CardData artifact; // c
|
||||||
|
CardData truth; // u
|
||||||
|
CardData notDead; // b
|
||||||
|
CardData wallOfDenial; // wu
|
||||||
|
CardData maelstromAngel; // wubrg
|
||||||
};
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
TEST_F(FilterTreeTest, TestOne)
|
// =====================================================================================================================
|
||||||
|
// acceptColor
|
||||||
|
// =====================================================================================================================
|
||||||
|
|
||||||
|
TEST_F(FilterTreeTest, Color)
|
||||||
{
|
{
|
||||||
ASSERT_TRUE(true);
|
FilterTree filterTree;
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "wu");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(island, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(artifact, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(FilterTreeTest, ColorColorless)
|
||||||
|
{
|
||||||
|
FilterTree filterTree;
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "c");
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(island, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(artifact, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(FilterTreeTest, ColorNot)
|
||||||
|
{
|
||||||
|
FilterTree filterTree;
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAndNot, "b");
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(island, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(artifact, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(FilterTreeTest, ColorAliases)
|
||||||
|
{
|
||||||
|
FilterTree filterTree;
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "green");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "grn");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "blue");
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "blu");
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "black");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(notDead, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "blk");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(notDead, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "red");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "white");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "wht");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "colorless");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(artifact, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "colourless");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(artifact, language));
|
||||||
|
filterTree.clear();
|
||||||
|
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColor, CardFilter::Type::TypeAnd, "none");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(artifact, language));
|
||||||
|
filterTree.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =====================================================================================================================
|
||||||
|
// acceptColorIdentity
|
||||||
|
// =====================================================================================================================
|
||||||
|
|
||||||
|
TEST_F(FilterTreeTest, ColorIdentity)
|
||||||
|
{
|
||||||
|
FilterTree filterTree;
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColorIdentity, CardFilter::Type::TypeAnd, "wu");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(island, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(artifact, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(FilterTreeTest, ColorIdentityColorless)
|
||||||
|
{
|
||||||
|
FilterTree filterTree;
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColorIdentity, CardFilter::Type::TypeAnd, "c");
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(island, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(artifact, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(FilterTreeTest, ColorIdentityNot)
|
||||||
|
{
|
||||||
|
FilterTree filterTree;
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColorIdentity, CardFilter::Type::TypeAndNot, "b");
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(island, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(artifact, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(FilterTreeTest, ColorIdentityMultiple)
|
||||||
|
{
|
||||||
|
// Simulate a WU commander.
|
||||||
|
FilterTree filterTree;
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColorIdentity, CardFilter::Type::TypeAndNot, "b");
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColorIdentity, CardFilter::Type::TypeAndNot, "r");
|
||||||
|
filterTree.termNode(CardFilter::Attr::AttrColorIdentity, CardFilter::Type::TypeAndNot, "g");
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(island, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(artifact, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(truth, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(notDead, language));
|
||||||
|
ASSERT_TRUE(filterTree.acceptsCard(wallOfDenial, language));
|
||||||
|
ASSERT_FALSE(filterTree.acceptsCard(maelstromAngel, language));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
@ -53,4 +216,3 @@ int main(int argc, char **argv)
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue