From 319a720d1b78439082463358d2496eacf653999a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 28 Jan 2021 01:06:09 +0100 Subject: [PATCH] [libcalamares Expand tests --- src/libcalamares/utils/Tests.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libcalamares/utils/Tests.cpp b/src/libcalamares/utils/Tests.cpp index 84449bdb9..3493f9579 100644 --- a/src/libcalamares/utils/Tests.cpp +++ b/src/libcalamares/utils/Tests.cpp @@ -562,6 +562,20 @@ LibCalamaresTests::testStringTruncation() cDebug() << "Result-line" << Logger::Quote << s; QCOMPARE( s.count( '\n' ), 4 ); } + + // Lines at both ends + { + auto s = truncateMultiLine( longString, LinesStartEnd { 2, 2 }, CharCount { sufficientLength } ); + QVERIFY( s.length() > 1 ); + cDebug() << "Result-line" << Logger::Quote << s; + QCOMPARE( s.count( '\n' ), 4 ); + + auto firsttwo = truncateMultiLine( s, LinesStartEnd { 2, 0 }, CharCount { sufficientLength } ); + auto lasttwo = truncateMultiLine( s, LinesStartEnd { 0, 2 }, CharCount { sufficientLength } ); + QCOMPARE( firsttwo + lasttwo, s ); + QVERIFY( longString.startsWith( firsttwo ) ); + QVERIFY( longString.endsWith( lasttwo ) ); + } }