Merge branch 'master' into game-time-part2-checkbox

This commit is contained in:
lilyhuang-github 2025-03-25 20:36:38 -04:00 committed by GitHub
commit dee3d6998f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
87 changed files with 3472 additions and 2613 deletions

View file

@ -51,3 +51,4 @@ target_link_libraries(password_hash_test cockatrice_common Threads::Threads ${GT
add_subdirectory(carddatabase)
add_subdirectory(loading_from_clipboard)
add_subdirectory(oracle)

View file

@ -22,6 +22,7 @@ add_executable(
../../cockatrice/src/game/cards/card_database_parser/card_database_parser.cpp
../../cockatrice/src/game/cards/card_database_parser/cockatrice_xml_3.cpp
../../cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp
../../cockatrice/src/game/cards/card_info.cpp
../../cockatrice/src/settings/settings_manager.cpp
carddatabase_test.cpp
mocks.cpp
@ -35,6 +36,7 @@ add_executable(
../../cockatrice/src/game/cards/card_database_parser/card_database_parser.cpp
../../cockatrice/src/game/cards/card_database_parser/cockatrice_xml_3.cpp
../../cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp
../../cockatrice/src/game/cards/card_info.cpp
../../cockatrice/src/game/filters/filter_card.cpp
../../cockatrice/src/game/filters/filter_string.cpp
../../cockatrice/src/game/filters/filter_tree.cpp

View file

@ -203,6 +203,9 @@ void SettingsCache::setPrintingSelectorSortOrder(int /* _printingSelectorSortOrd
void SettingsCache::setPrintingSelectorCardSize(int /* _printingSelectorCardSize */)
{
}
void SettingsCache::setIncludeOnlineOnlyCards(bool /* _includeOnlineOnlyCards */)
{
}
void SettingsCache::setPrintingSelectorNavigationButtonsVisible(QT_STATE_CHANGED_T /* _navigationButtonsVisible */)
{
}
@ -391,6 +394,9 @@ void SettingsCache::setUpdateReleaseChannelIndex(int /* value */)
void SettingsCache::setMaxFontSize(int /* _max */)
{
}
void SettingsCache::setRoundCardCorners(bool /* _roundCardCorners */)
{
}
void PictureLoader::clearPixmapCache(CardInfoPtr /* card */)
{

View file

@ -18,7 +18,7 @@ void testEmpty(const QString &clipboard)
QString cp(clipboard);
DeckList deckList;
QTextStream stream(&cp); // text stream requires local copy
deckList.loadFromStream_Plain(stream);
deckList.loadFromStream_Plain(stream, false);
ASSERT_TRUE(deckList.getCardList().isEmpty());
}
@ -28,7 +28,7 @@ void testDeck(const QString &clipboard, const Result &result)
QString cp(clipboard);
DeckList deckList;
QTextStream stream(&cp); // text stream requires local copy
deckList.loadFromStream_Plain(stream);
deckList.loadFromStream_Plain(stream, false);
ASSERT_EQ(result.name, deckList.getName().toStdString());
ASSERT_EQ(result.comments, deckList.getComments().toStdString());

View file

@ -0,0 +1,11 @@
add_executable(parse_cipt_test ../../oracle/src/parsehelpers.cpp parse_cipt_test.cpp)
if(NOT GTEST_FOUND)
add_dependencies(parse_cipt_test gtest)
endif()
set(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Widgets)
target_link_libraries(parse_cipt_test cockatrice_common Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES})
add_test(NAME parse_cipt_test COMMAND parse_cipt_test)

View file

@ -0,0 +1,219 @@
#include "../../oracle/src/parsehelpers.h"
#include "gtest/gtest.h"
TEST(ParseCiptTest, parsesThisEntersTapped)
{
auto name = "Boring Fields";
auto text = "This land enters tapped.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesThisEntersTheBattlefieldTapped)
{
auto name = "Boring Fields";
auto text = "This land enters the battlefield tapped.\n"
"{T}: Add {G}.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesItEntersTappedAtEndOfSentence)
{
auto name = "Shocking Fields";
auto text = "As this land enters, you may pay 2 life. If you don't, it enters tapped.\n"
"{T}: Add {G}.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesThisEntersTappedWhenNotOnFirstLine)
{
auto name = "Boring Fields";
auto text = "Flying\n"
"This land enters tapped.\n"
"{T}: Add {G}.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesFullNameWithUnderscoreAppendedText)
{
auto name = "Boring Fields_SL50";
auto text = "Boring Fields enters tapped.\n"
"{T}: Add {G}.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesFullNameWithBracketsAppendedText)
{
auto name = "Boring Fields (SL50)";
auto text = "Boring Fields enters tapped.\n"
"{T}: Add {G}.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesFullNameWithComma)
{
auto name = "Bob, the Legend";
auto text = "Bob, the Legend enters tapped.\n"
"Whenever Bob attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesFullNameWithCommaAtEndOfSentence)
{
auto name = "Bob, the Legend";
auto text = "As Bob, the Legend enters, you may pay 2 life. If you don't, Bob, the Legend enters tapped.\n"
"Whenever Bob attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesFullNameWithApostropheAtEndOfSentence)
{
auto name = "Bob's Bobber";
auto text = "As Bob's Bobber enters, you may pay 2 life. If you don't, Bob's Bobber enters tapped.\n"
"Whenever Bob attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesShortnameEndingWithComma)
{
auto name = "Bob, the Legend";
auto text = "Bob enters tapped.\n"
"Whenever Bob attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesShortnameEndingWithSpace)
{
auto name = "Bob the Legend";
auto text = "Bob enters tapped.\n"
"Whenever Bob attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesMultiWordShortnameEndingWithComma)
{
auto name = "Bob Dod, the Legend";
auto text = "Bob Dod enters tapped.\n"
"Whenever Bob Dod attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesMultiWordShortnameEndingWithSpace)
{
auto name = "Bob Dod the Legend";
auto text = "Bob Dod enters tapped.\n"
"Whenever Bob Dod attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesShortnameEndingWithSpaceWithUnderscoreAppendedText)
{
auto name = "Bob the Legend_SL50";
auto text = "Bob enters tapped.\n"
"Whenever Bob attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesShortnameEndingWithSpaceWithBracketsAppendedText)
{
auto name = "Bob the Legend (SL50)";
auto text = "Bob enters tapped.\n"
"Whenever Bob attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesMultiWordShortnameEndingWithSpaceWithUnderscoreAppendedText)
{
auto name = "Bob Dod the Legend_SL50";
auto text = "Bob Dod enters tapped.\n"
"Whenever Bob Dod attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesMultiWordShortnameEndingWithSpaceWithBracketsAppendedText)
{
auto name = "Bob Dod the Legend (SL50)";
auto text = "Bob Dod enters tapped.\n"
"Whenever Bob Dod attacks, you win the game.";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, rejectsEmptyText)
{
auto name = "Vanilla Dude";
auto text = "";
ASSERT_FALSE(parseCipt(name, text));
}
TEST(ParseCiptTest, rejectsEntersTappedUnless)
{
auto name = "Fast Fields";
auto text = "This land enters tapped unless you control another land.";
ASSERT_FALSE(parseCipt(name, text));
}
TEST(ParseCiptTest, rejectsWhenNameIsDifferent)
{
auto name = "Boring Fields";
auto text = "Fast Fields enters tapped.";
ASSERT_FALSE(parseCipt(name, text));
}
TEST(ParseCiptTest, rejectsOtherCreaturesEnterTapped)
{
auto name = "Imposing Guy";
auto text = "Other creatures enter tapped.";
ASSERT_FALSE(parseCipt(name, text));
}
TEST(ParseCiptTest, rejectsAbilityGrantingEntersTapped)
{
auto name = "Imposing Guy";
auto text = "Other creatures have \"This creature enters tapped\".";
ASSERT_FALSE(parseCipt(name, text));
}
TEST(ParseCiptTest, parsesEntersTappedAndAbilityGrantingEntersTappedOnSameCard)
{
auto name = "Imposing Guy";
auto text = "This creature enters tapped."
"Other creatures have \"This creature enters tapped\".";
ASSERT_TRUE(parseCipt(name, text));
}
TEST(ParseCiptTest, rejectsItEntersTappedAndAttacking)
{
auto name = "Token Maker";
auto text = "When Token Maker attacks, create a token. It enters tapped and attacking.";
ASSERT_FALSE(parseCipt(name, text));
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}