[libcalamares] Expand tests for printable entropy

This commit is contained in:
Adriaan de Groot 2020-02-12 12:22:02 +01:00
parent 090716ba4f
commit a11280b427
2 changed files with 28 additions and 0 deletions

View file

@ -224,3 +224,30 @@ LibCalamaresTests::testPrintableEntropy()
QVERIFY( c.cell() < 127 );
}
}
void
LibCalamaresTests::testOddSizedPrintable()
{
QString s;
for ( int l = 0; l <= 37; ++l )
{
auto r = CalamaresUtils::getPrintableEntropy( l, s );
if ( l == 0 )
{
QCOMPARE( r, CalamaresUtils::EntropySource::None );
}
else
{
QVERIFY( r != CalamaresUtils::EntropySource::None );
}
QCOMPARE( s.length(), l );
for ( QChar c : s )
{
QVERIFY( c.isPrint() );
QCOMPARE( c.row(), 0 );
QVERIFY( c.cell() > 32 ); // ASCII SPACE
QVERIFY( c.cell() < 127 );
}
}
}

View file

@ -43,6 +43,7 @@ private Q_SLOTS:
/** @brief Tests the entropy functions. */
void testEntropy();
void testPrintableEntropy();
void testOddSizedPrintable();
};
#endif