* CardDB: merge all card properties in a new structure * Pre Json parser changes * Cockatrice: use qt's builtin json support * Move qt-json src dir from cockatrice to oracle * Add dummy cockatricexml4 parser (yet to be implemented) * Implement a new parser and xml format * cockatricexml4: new xml parser following the "generic properties hash" pattern; * oracleimporter: refactor the parsing code to better adapt to cockatricexml4; rewrote split cards parsing * carddb: change "colors" from a stringlist to a string * carddb: move the getMainCardType() method to the cockatricexml3 parser * * CardInfo: show all properties (stil missing: nice name + translation) * Rework the "add related card" feature so that it doesn't change the card name in the carddb Also, fix token count display * Picture loader: Added support for transform cards * Fix side information for flip cards Mtgjson uses side a/b for flip cards, while scryfall doesn't * Pictureloader: dynamic tag resolution from card properties Examples old => new * !cardid! => !set:muid! * !uuid! => !set:uuid! * !collectornumber! => !set:num! New examples: * !prop:type! * !prop:manacost! * Start moving mtg-related property names to a specific file * Clangify * Fix tests * Make gcc an happy puppy * Revert "Make gcc an happy puppy" This reverts commit 446ec5f27516c4d3b32dbfc79557f4827c5c5bdf. * Some gcc fixes * Share set list between different db parsers, so they won't overwrite one each other * All glory to the hypnoclangifier! * Fix test compilation * Cleanup edited files in the prior PR. (#3519) * Cleanup edited files in the prior PR. Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com> * Fix includes Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com> * Update carddatabase.h
90 lines
No EOL
2.7 KiB
C++
90 lines
No EOL
2.7 KiB
C++
#include "gtest/gtest.h"
|
|
|
|
#include "carddatabase_test.h"
|
|
|
|
void CardDatabaseSettings::setSortKey(QString /* shortName */, unsigned int /* sortKey */){};
|
|
void CardDatabaseSettings::setEnabled(QString /* shortName */, bool /* enabled */){};
|
|
void CardDatabaseSettings::setIsKnown(QString /* shortName */, bool /* isknown */){};
|
|
unsigned int CardDatabaseSettings::getSortKey(QString /* shortName */)
|
|
{
|
|
return 0;
|
|
};
|
|
bool CardDatabaseSettings::isEnabled(QString /* shortName */)
|
|
{
|
|
return true;
|
|
};
|
|
bool CardDatabaseSettings::isKnown(QString /* shortName */)
|
|
{
|
|
return true;
|
|
};
|
|
|
|
SettingsCache::SettingsCache()
|
|
{
|
|
cardDatabaseSettings = new CardDatabaseSettings();
|
|
};
|
|
SettingsCache::~SettingsCache()
|
|
{
|
|
delete cardDatabaseSettings;
|
|
};
|
|
QString SettingsCache::getCustomCardDatabasePath() const
|
|
{
|
|
return QString("%1/customsets/").arg(CARDDB_DATADIR);
|
|
}
|
|
QString SettingsCache::getCardDatabasePath() const
|
|
{
|
|
return QString("%1/cards.xml").arg(CARDDB_DATADIR);
|
|
}
|
|
QString SettingsCache::getTokenDatabasePath() const
|
|
{
|
|
return QString("%1/tokens.xml").arg(CARDDB_DATADIR);
|
|
}
|
|
QString SettingsCache::getSpoilerCardDatabasePath() const
|
|
{
|
|
return QString("%1/spoiler.xml").arg(CARDDB_DATADIR);
|
|
}
|
|
CardDatabaseSettings &SettingsCache::cardDatabase() const
|
|
{
|
|
return *cardDatabaseSettings;
|
|
}
|
|
|
|
SettingsCache *settingsCache;
|
|
|
|
void PictureLoader::clearPixmapCache(CardInfoPtr /* card */)
|
|
{
|
|
}
|
|
|
|
namespace
|
|
{
|
|
|
|
TEST(CardDatabaseTest, LoadXml)
|
|
{
|
|
settingsCache = new SettingsCache;
|
|
CardDatabase *db = new CardDatabase;
|
|
|
|
// ensure the card database is empty at start
|
|
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty at start";
|
|
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty at start";
|
|
ASSERT_EQ(0, db->getAllMainCardTypes().size()) << "Types not empty at start";
|
|
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status at start";
|
|
|
|
// 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(Ok, db->getLoadStatus()) << "Wrong status after load";
|
|
|
|
// ensure the card database is empty after clear()
|
|
db->clear();
|
|
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty after clear";
|
|
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty after clear";
|
|
ASSERT_EQ(0, db->getAllMainCardTypes().size()) << "Types not empty after clear";
|
|
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status after clear";
|
|
}
|
|
} // namespace
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
} |