mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Oracle/Tests] Pin cmc coercion in CI run; scope the reserve pass
The #7214 coercion assertion lived only in oracle_importer_benchmark_test, which gets no add_test and so never runs under ctest. Add NumericManaValueCoercedToCmc and LegacyConvertedManaCostCoercedToCmc to oracle_importer_test (a CI-ran binary): manaValue/convertedManaCost are JSON numbers in AllPrintings, and QJsonValue::toString() would drop them to an empty cmc without the #7214 coercion fix. Wrap the distinct-name reserve pass in a bare block so the ~35k name QStrings are handed back before the memory-heavy import loop starts.
This commit is contained in:
parent
770282c5b5
commit
bd1fb69800
2 changed files with 36 additions and 5 deletions
|
|
@ -555,13 +555,17 @@ int OracleImporter::startImport()
|
|||
// ships ~100k printings for ~35k names, so reserving the printing count
|
||||
// would overallocate ~3x (against this stack's RAM goal). Collecting
|
||||
// distinct names is cheap — one pass over the already-parsed name fields.
|
||||
QSet<QString> distinctNames;
|
||||
for (const SetToDownload &curSetToParse : allSets) {
|
||||
for (const QJsonValue &cardValue : curSetToParse.getCards()) {
|
||||
distinctNames.insert(cardValue.toObject().value("name").toString());
|
||||
{
|
||||
QSet<QString> distinctNames;
|
||||
for (const SetToDownload &curSetToParse : allSets) {
|
||||
for (const QJsonValue &cardValue : curSetToParse.getCards()) {
|
||||
distinctNames.insert(cardValue.toObject().value("name").toString());
|
||||
}
|
||||
}
|
||||
cards.reserve(distinctNames.size());
|
||||
// The set goes out of scope here, handing the ~35k name QStrings back
|
||||
// to the allocator before the (memory-heavy) import loop starts.
|
||||
}
|
||||
cards.reserve(distinctNames.size());
|
||||
|
||||
// add an empty set for tokens
|
||||
CardSetPtr tokenSet =
|
||||
|
|
|
|||
|
|
@ -482,6 +482,33 @@ TEST_F(OracleImporterTest, ManaCostStripsBraces)
|
|||
ASSERT_EQ(result->getProperty("manacost"), "2WB");
|
||||
}
|
||||
|
||||
// cmc comes through as a JSON number ("convertedManaCost"/"manaValue" are
|
||||
// floats in AllPrintings), so this pins the number-to-text coercion that
|
||||
// QJsonValue::toString() dropped in #7214.
|
||||
TEST_F(OracleImporterTest, NumericManaValueCoercedToCmc)
|
||||
{
|
||||
QJsonObject card = makeCard("Cmc Card");
|
||||
card["manaValue"] = 3;
|
||||
QJsonArray cards{card};
|
||||
|
||||
importer->importCardsFromSet(set, cards);
|
||||
auto result = importer->getCardList().value("Cmc Card");
|
||||
ASSERT_FALSE(result.isNull());
|
||||
ASSERT_EQ(result->getProperty("cmc"), "3");
|
||||
}
|
||||
|
||||
TEST_F(OracleImporterTest, LegacyConvertedManaCostCoercedToCmc)
|
||||
{
|
||||
QJsonObject card = makeCard("Legacy Cmc Card");
|
||||
card["convertedManaCost"] = 3.0;
|
||||
QJsonArray cards{card};
|
||||
|
||||
importer->importCardsFromSet(set, cards);
|
||||
auto result = importer->getCardList().value("Legacy Cmc Card");
|
||||
ASSERT_FALSE(result.isNull());
|
||||
ASSERT_EQ(result->getProperty("cmc"), "3");
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Card deduplication tests
|
||||
// ============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue