Catch roff parse errors when checking for grid data

This commit is contained in:
Magne Sjaastad committed 2026-09-28 09:18:41 +02:00
1 parent 17e8c96e00
commit 0db64b400b
2 files changed
+32 -9

No files matched your search

@@ -16,6 +16,7 @@
#include <QDir>
#include <QFile>
#include <QTemporaryDir>
#include <algorithm>
#include <cmath>
@@ -179,6 +180,20 @@ TEST( RifRoffFileTools, HasGridDataFalseForMissingFile )
EXPECT_FALSE( RifRoffFileTools::hasGridData( filePath ) );
}
TEST( RifRoffFileTools, HasGridDataFalseForMalformedFile )
{
QTemporaryDir tempDir;
ASSERT_TRUE( tempDir.isValid() );
auto filePath = tempDir.filePath( "malformed.roff" );
QFile file( filePath );
ASSERT_TRUE( file.open( QIODevice::WriteOnly ) );
file.write( "this is not a roff file" );
file.close();
EXPECT_FALSE( RifRoffFileTools::hasGridData( filePath ) );
}
//--------------------------------------------------------------------------------------------------
// openGridFile on a stream is the entry point used when the roff data is not a file on disk, e.g. a
// blob downloaded from Sumo.