update handling of keywords: AND, OR, NOT in card search (#5788)

* update hnadling of keywords: AND, OR, NOT in card search

* added and

* update test

* update test

* update OR to not be [oO][rR] and just look for OR

* keyword testing

* adjusted new test

* implement test case for cards with keyword in name

* implement test case to cards with keyword in name

* format

* update test case

* change test cas

* update truth test case

* changed test card search from real cards to fake and added cards

* Update tests/carddatabase/data/cards.xml

Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com>

* Update tests/carddatabase/filter_string_test.cpp

Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com>

* Update tests/carddatabase/filter_string_test.cpp

Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com>

* update formatting

* update cardatabase_test to include +2 cards

* update test case +1 set + 1 type

---------

Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com>
This commit is contained in:
lilyhuang-github
2025-04-20 00:08:00 -04:00
committed by GitHub
parent 26dcb015ce
commit 574ea01e08
4 changed files with 43 additions and 10 deletions

View File

@@ -18,9 +18,9 @@ TEST(CardDatabaseTest, LoadXml)
// load dummy cards and test result
db->loadCardDatabases();
ASSERT_EQ(6, db->getCardList().size()) << "Wrong card count after load";
ASSERT_EQ(3, db->getSetList().size()) << "Wrong sets count after load";
ASSERT_EQ(2, db->getAllMainCardTypes().size()) << "Wrong types count after load";
ASSERT_EQ(8, db->getCardList().size()) << "Wrong card count after load";
ASSERT_EQ(4, db->getSetList().size()) << "Wrong sets count after load";
ASSERT_EQ(3, db->getAllMainCardTypes().size()) << "Wrong types count after load";
ASSERT_EQ(Ok, db->getLoadStatus()) << "Wrong status after load";
// ensure the card database is empty after clear()

View File

@@ -31,5 +31,31 @@
<pt>4/4</pt>
</prop>
</card>
<card>
<name>Not Dead</name>
<set> Not a Card</set>
<tablerow>0</tablerow>
<text>Dead!</text>
<prop>
<muid>333</muid>
<colors>B</colors>
<manacost>B</manacost>
<cmc>1</cmc>
<maintype>Instant</maintype>
</prop>
</card>
<card>
<name>Truth</name>
<set> Not a Card</set>
<tablerow>0</tablerow>
<text>Truth!</text>
<prop>
<muid>444</muid>
<colors>U</colors>
<manacost>2U</manacost>
<cmc>2</cmc>
<maintype>Instant</maintype>
</prop>
</card>
</cards>
</cockatrice_carddatabase>

View File

@@ -19,11 +19,14 @@ protected:
void SetUp() override
{
cat = CardDatabaseManager::getInstance()->getCardBySimpleName("Cat");
notDeadAfterAll = CardDatabaseManager::getInstance()->getCardBySimpleName("Not Dead");
truth = CardDatabaseManager::getInstance()->getCardBySimpleName("Truth");
}
// void TearDown() override {}
CardData cat;
CardData notDeadAfterAll;
CardData truth;
};
QUERY(Empty, cat, "", true)
@@ -31,14 +34,18 @@ QUERY(Typing, cat, "t", true)
QUERY(NonMatchingType, cat, "t:kithkin", false)
QUERY(MatchingType, cat, "t:creature", true)
QUERY(Not1, cat, "not t:kithkin", true)
QUERY(Not2, cat, "not t:creature", false)
QUERY(Not1, cat, "NOT t:kithkin", true)
QUERY(Not2, cat, "NOT t:creature", false)
QUERY(NonKeyword1, cat, "not t:kithkin", false)
QUERY(NonKeyword2, cat, "t:bat or t:creature", false)
QUERY(NonKeyword3, notDeadAfterAll, "not dead", true)
QUERY(NonKeyword4, truth, "truth or trail", false)
QUERY(Case, cat, "t:cReAtUrE", true)
QUERY(And, cat, "t:creature t:creature", true)
QUERY(And2, cat, "t:creature t:sorcery", false)
QUERY(Or, cat, "t:bat or t:creature", true)
QUERY(Or, cat, "t:bat OR t:creature", true)
QUERY(Cmc1, cat, "cmc=2", true)
QUERY(Cmc2, cat, "cmc>3", false)