#include "gtest/gtest.h" #include #include static constexpr int amount = 1e5; QString repeatDeck; QString numberDeck; QString uniquesDeck; QString uniquesXorDeck; QString duplicatesDeck; TEST(DeckHashTest, RepeatTest) { DeckList decklist(repeatDeck); for (int i = 0; i < amount; ++i) { decklist.getDeckHash(); decklist.refreshDeckHash(); } auto hash = decklist.getDeckHash().toStdString(); ASSERT_EQ(hash, "5cac19qm") << "The hash does not match!"; } TEST(DeckHashTest, NumberTest) { DeckList decklist(numberDeck); auto hash = decklist.getDeckHash().toStdString(); ASSERT_EQ(hash, "e0m38p19") << "The hash does not match!"; } TEST(DeckHashTest, UniquesTest) { DeckList decklist(uniquesDeck); auto hash = decklist.getDeckHash().toStdString(); ASSERT_EQ(hash, "88prk025") << "The hash does not match!"; } TEST(DeckHashTest, UniquesTestXor) { DeckList decklist(uniquesXorDeck); auto hash = decklist.getDeckHash().toStdString(); ASSERT_EQ(hash, "hkn6q4pf") << "The hash does not match!"; } TEST(DeckHashTest, DuplicatesTest) { DeckList decklist(duplicatesDeck); auto hash = decklist.getDeckHash().toStdString(); ASSERT_EQ(hash, "ekt6tg1h") << "The hash does not match!"; } int main(int argc, char **argv) { const QString deckStart = R"()"; const QString deckEnd = R"()"; repeatDeck = deckStart + R"()" + deckEnd; numberDeck = deckStart + QString(R"()").arg(amount) + deckEnd; QStringList deckString{deckStart}; QStringList deckStringXor = deckString; int len = QString::number(amount).length(); for (int i = 0; i < amount; ++i) { // creates already sorted list deckString << R"()"; // xor in order to mess with sorting deckStringXor << R"()"; } deckString << deckEnd; deckStringXor << deckEnd; uniquesDeck = deckString.join(""); uniquesXorDeck = deckStringXor.join(""); duplicatesDeck = deckStart + QString(R"()").repeated(amount) + deckEnd; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }