mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 17:15:09 -07:00
This commit is contained in:
parent
6823d54c1e
commit
276873f0bd
2 changed files with 112 additions and 17 deletions
|
|
@ -2,6 +2,8 @@
|
|||
#include "test_card_database_path_provider.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include <libcockatrice/card/card_info.h>
|
||||
#include <libcockatrice/card/printing/printing_info.h>
|
||||
#include <libcockatrice/filters/filter_string.h>
|
||||
#include <libcockatrice/interfaces/noop_card_preference_provider.h>
|
||||
#include <libcockatrice/interfaces/noop_card_set_priority_controller.h>
|
||||
|
|
@ -71,10 +73,71 @@ QUERY(Color2, cat, "c:gw", true)
|
|||
QUERY(Color3, cat, "c!g", true)
|
||||
QUERY(Color4, cat, "c!gw", false)
|
||||
|
||||
QUERY(SetCodeCaseInsensitive1, cat, "set:cat", true)
|
||||
QUERY(SetCodeCaseInsensitive2, cat, "set:CAT", true)
|
||||
QUERY(SetCodeCaseInsensitive3, cat, "set:CAt", true)
|
||||
QUERY(SetCodeShortForm, cat, "e:cat", true)
|
||||
QUERY(SetCodeWrongSet, cat, "set:who", false)
|
||||
QUERY(SetCodeWrongSet2, doctor, "set:cat", false)
|
||||
|
||||
QUERY(BracketNextToUnquotedString, cat, "(o:woof OR o:meow)", true)
|
||||
|
||||
} // namespace
|
||||
|
||||
class SetQuery : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
// EOE and EOC share a release date, like a set and its Commander counterpart.
|
||||
const QDate sharedReleaseDate(2026, 3, 13);
|
||||
mainSet = CardSet::newInstance(&controller, "EOE", "Edge of Eternities", "expansion", sharedReleaseDate,
|
||||
CardSet::PriorityPrimary);
|
||||
commanderSet = CardSet::newInstance(&controller, "EOC", "Edge of Eternities Commander", "commander",
|
||||
sharedReleaseDate, CardSet::PrioritySecondary);
|
||||
|
||||
inBothSets = newCardWithPrintings({{"EOE", mainSet}, {"EOC", commanderSet}});
|
||||
onlyInCommanderSet = newCardWithPrintings({{"EOC", commanderSet}});
|
||||
}
|
||||
|
||||
CardInfoPtr newCardWithPrintings(const QList<QPair<QString, CardSetPtr>> &printings)
|
||||
{
|
||||
SetToPrintingsMap setsInfo;
|
||||
for (const auto &printing : printings) {
|
||||
setsInfo[printing.first].append(PrintingInfo(printing.second));
|
||||
}
|
||||
return CardInfo::newInstance("Test Card", "", false, {}, {}, {}, setsInfo, CardInfo::UiAttributes());
|
||||
}
|
||||
|
||||
NoopCardSetPriorityController controller;
|
||||
CardSetPtr mainSet;
|
||||
CardSetPtr commanderSet;
|
||||
CardInfoPtr inBothSets;
|
||||
CardInfoPtr onlyInCommanderSet;
|
||||
};
|
||||
|
||||
TEST_F(SetQuery, ExactMatchSeparatesSameDaySets)
|
||||
{
|
||||
EXPECT_TRUE(FilterString("set:EOE").check(inBothSets));
|
||||
EXPECT_TRUE(FilterString("e:EOE").check(inBothSets));
|
||||
EXPECT_TRUE(FilterString("set:EOC").check(inBothSets));
|
||||
EXPECT_FALSE(FilterString("set:EOE").check(onlyInCommanderSet));
|
||||
EXPECT_TRUE(FilterString("set:EOC").check(onlyInCommanderSet));
|
||||
}
|
||||
|
||||
TEST_F(SetQuery, ExactMatchIsCaseInsensitive)
|
||||
{
|
||||
EXPECT_TRUE(FilterString("set:eoe").check(inBothSets));
|
||||
EXPECT_TRUE(FilterString("set:EoE").check(inBothSets));
|
||||
EXPECT_FALSE(FilterString("set:eoe").check(onlyInCommanderSet));
|
||||
}
|
||||
|
||||
TEST_F(SetQuery, NotEqualsMatchesPrintingsOutsideTheSet)
|
||||
{
|
||||
EXPECT_FALSE(FilterString("set!EOE").check(inBothSets));
|
||||
EXPECT_TRUE(FilterString("set!EOE").check(onlyInCommanderSet));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue