ignore "deck" at start of a list add tests add tests to clangify.sh
This commit is contained in:
parent
b940e17fe7
commit
1c48656623
3 changed files with 48 additions and 2 deletions
|
@ -11,7 +11,8 @@ cd "${BASH_SOURCE%/*}/" || exit 2 # could not find path, this could happen with
|
||||||
include=("common" \
|
include=("common" \
|
||||||
"cockatrice/src" \
|
"cockatrice/src" \
|
||||||
"oracle/src" \
|
"oracle/src" \
|
||||||
"servatrice/src")
|
"servatrice/src" \
|
||||||
|
"tests")
|
||||||
exclude=("servatrice/src/smtp" \
|
exclude=("servatrice/src/smtp" \
|
||||||
"common/sfmt" \
|
"common/sfmt" \
|
||||||
"common/lib" \
|
"common/lib" \
|
||||||
|
|
|
@ -492,7 +492,9 @@ bool DeckList::loadFromStream_Plain(QTextStream &in)
|
||||||
const QRegularExpression reEmpty("^\\s*$");
|
const QRegularExpression reEmpty("^\\s*$");
|
||||||
const QRegularExpression reComment("[\\w\\[\\(\\{].*$", QRegularExpression::UseUnicodePropertiesOption);
|
const QRegularExpression reComment("[\\w\\[\\(\\{].*$", QRegularExpression::UseUnicodePropertiesOption);
|
||||||
const QRegularExpression reSBMark("^\\s*sb:\\s*(.+)", QRegularExpression::CaseInsensitiveOption);
|
const QRegularExpression reSBMark("^\\s*sb:\\s*(.+)", QRegularExpression::CaseInsensitiveOption);
|
||||||
const QRegularExpression reSBComment("sideboard", QRegularExpression::CaseInsensitiveOption);
|
const QRegularExpression reSBComment("^sideboard\\b.*$", QRegularExpression::CaseInsensitiveOption);
|
||||||
|
const QRegularExpression reDeckComment("^((main)?deck(list)?|mainboard)\\b",
|
||||||
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
|
|
||||||
// simplified matches
|
// simplified matches
|
||||||
const QRegularExpression reMultiplier("^[xX\\(\\[]*(\\d+)[xX\\*\\)\\]]* ?(.+)");
|
const QRegularExpression reMultiplier("^[xX\\(\\[]*(\\d+)[xX\\*\\)\\]]* ?(.+)");
|
||||||
|
@ -563,6 +565,16 @@ bool DeckList::loadFromStream_Plain(QTextStream &in)
|
||||||
}
|
}
|
||||||
comments.chop(1); // remove last newline
|
comments.chop(1); // remove last newline
|
||||||
|
|
||||||
|
// discard empty lines
|
||||||
|
while (index < max_line && inputs.at(index).contains(reEmpty)) {
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
|
// discard line if it starts with deck or mainboard, all cards until the sideboard starts are in the mainboard
|
||||||
|
if (inputs.at(index).contains(reDeckComment)) {
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
// parse decklist
|
// parse decklist
|
||||||
for (; index < max_line; ++index) {
|
for (; index < max_line; ++index) {
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,39 @@ TEST(LoadingFromClipboardTest, CommentsBeforeCardsTesting)
|
||||||
testDeck(clipboard, result);
|
testDeck(clipboard, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(LoadingFromClipboardTest, mainboardAsLine)
|
||||||
|
{
|
||||||
|
QString clipboard("// Deck Name\n"
|
||||||
|
"\n"
|
||||||
|
"MainBoard: 3 cards\n"
|
||||||
|
"3 card\n"
|
||||||
|
"\n"
|
||||||
|
"SideBoard: 2 cards\n"
|
||||||
|
"2 sidecard\n");
|
||||||
|
|
||||||
|
Result result("Deck Name", "", {{"card", 3}}, {{"sidecard", 2}});
|
||||||
|
testDeck(clipboard, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(LoadingFromClipboardTest, deckAsCard)
|
||||||
|
{
|
||||||
|
QString clipboard("6 Deck of Cards But Animated\n"
|
||||||
|
"\n"
|
||||||
|
"7 Sideboard Card\n");
|
||||||
|
|
||||||
|
Result result("", "", {{"Deck of Cards But Animated", 6}}, {{"Sideboard Card", 7}});
|
||||||
|
testDeck(clipboard, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(LoadingFromClipboardTest, emptyMainBoard)
|
||||||
|
{
|
||||||
|
QString clipboard("deck\n"
|
||||||
|
"\n"
|
||||||
|
"sideboard\n");
|
||||||
|
|
||||||
|
testEmpty(clipboard);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
Loading…
Reference in a new issue