mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
Hashing tests (#5026)
* add deck hashing tests * format * fix header * fix cmakelists * fix test * add 5 second timeout to test let the optimising begin * expand tests * remove debug message * manually format * I installed cmake format from the aur * use decklist library * format
This commit is contained in:
parent
421d6b334a
commit
521046fb09
5 changed files with 124 additions and 8 deletions
|
|
@ -3,22 +3,32 @@
|
|||
#include <QTextStream>
|
||||
#include <libcockatrice/deck_list/tree/deck_list_card_node.h>
|
||||
|
||||
void testEmpty(const QString &clipboard)
|
||||
DeckList getDeckList(const QString &clipboard)
|
||||
{
|
||||
QString cp(clipboard);
|
||||
DeckList deckList;
|
||||
QString cp(clipboard);
|
||||
QTextStream stream(&cp); // text stream requires local copy
|
||||
deckList.loadFromStream_Plain(stream, false);
|
||||
return deckList;
|
||||
}
|
||||
|
||||
void testEmpty(const QString &clipboard)
|
||||
{
|
||||
DeckList deckList = getDeckList(clipboard);
|
||||
|
||||
ASSERT_TRUE(deckList.getCardList().isEmpty());
|
||||
}
|
||||
|
||||
void testHash(const QString &clipboard, const std::string &hash)
|
||||
{
|
||||
DeckList deckList = getDeckList(clipboard);
|
||||
|
||||
ASSERT_EQ(deckList.getDeckHash().toStdString(), hash);
|
||||
}
|
||||
|
||||
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, false);
|
||||
DeckList deckList = getDeckList(clipboard);
|
||||
|
||||
ASSERT_EQ(result.name, deckList.getName().toStdString());
|
||||
ASSERT_EQ(result.comments, deckList.getComments().toStdString());
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ struct Result
|
|||
};
|
||||
|
||||
void testEmpty(const QString &clipboard);
|
||||
|
||||
void testHash(const QString &clipboard, const std::string &hash);
|
||||
void testDeck(const QString &clipboard, const Result &result);
|
||||
|
||||
#endif // CLIPBOARD_TESTING_H
|
||||
|
|
|
|||
|
|
@ -203,6 +203,22 @@ TEST(LoadingFromClipboardTest, emptyMainBoard)
|
|||
testEmpty(clipboard);
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, emptyHash)
|
||||
{
|
||||
QString clipboard("");
|
||||
|
||||
testHash(clipboard, "r8sq7riu");
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, deckHash)
|
||||
{
|
||||
QString clipboard("1 Mountain\n"
|
||||
"2 Island\n"
|
||||
"SB: 3 Forest\n");
|
||||
|
||||
testHash(clipboard, "5cac19qm");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue