Fix blank line between comments issue (#3407)
* Added failing test to demonstrate issue with dec loading * Prevents empty lines between comments from being interpreted as the start of the sideboard
This commit is contained in:
parent
cf9fdcd09e
commit
bc2cb59c50
2 changed files with 18 additions and 2 deletions
|
@ -542,10 +542,11 @@ bool DeckList::loadFromStream_Plain(QTextStream &in)
|
|||
}
|
||||
|
||||
// If we have a blank line and it's the _ONLY_ blank line in the paste
|
||||
// and it follows at least one valid card
|
||||
// Then we assume it means to start the sideboard section of the paste.
|
||||
// If we have the word "Sideboard" appear on any line, then that will
|
||||
// also indicate the start of the sideboard.
|
||||
if ((line.isEmpty() && blankLines == 1) || line.startsWith("sideboard")) {
|
||||
if ((line.isEmpty() && blankLines == 1 && okRows > 0) || line.startsWith("sideboard")) {
|
||||
inSideboard = true;
|
||||
continue; // The line isn't actually a card
|
||||
}
|
||||
|
|
|
@ -228,6 +228,21 @@ TEST(LoadingFromClipboardTest, LotsOfStuffInBulkTesting)
|
|||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, CommentsBeforeCardsTesting)
|
||||
{
|
||||
QString *clipboard = new QString("//NAME: Title from Website.com\n"
|
||||
"\n"
|
||||
"//Main\n"
|
||||
"1 test1\n");
|
||||
DeckList *decklist = fromClipboard(clipboard);
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
decklist->forEachCard(decklistBuilder);
|
||||
CardRows expectedMainboard = CardRows({{"test1", 1}});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
Loading…
Reference in a new issue