13
13
#include " Common.h"
14
14
#include " DatasetCommon.h"
15
15
16
- void SpreadsheetsTest::initTestCase ()
16
+ void SpreadsheetsTest::initTestCase () const
17
17
{
18
18
// generateExpectedData();
19
19
}
20
20
21
- void SpreadsheetsTest::testDefinition_data ()
21
+ void SpreadsheetsTest::testDefinition_data () const
22
22
{
23
23
addTestCasesForFileNames (testFileNames_);
24
24
}
@@ -29,7 +29,7 @@ void SpreadsheetsTest::testDefinition()
29
29
DatasetCommon::checkDefinition (fileName, Common::getSpreadsheetsDir ());
30
30
}
31
31
32
- void SpreadsheetsTest::testData_data ()
32
+ void SpreadsheetsTest::testData_data () const
33
33
{
34
34
addTestCasesForFileNames (testFileNames_);
35
35
}
@@ -54,7 +54,7 @@ void SpreadsheetsTest::testDamagedFiles()
54
54
QVERIFY (!dataset->initialize ());
55
55
}
56
56
57
- void SpreadsheetsTest::compareExpectedDefinitionsOfOdsAndXlsx_data ()
57
+ void SpreadsheetsTest::compareExpectedDefinitionsOfOdsAndXlsx_data () const
58
58
{
59
59
addTestCaseForOdsAndXlsxComparison (
60
60
QStringLiteral (" Compare definition dumps" ));
@@ -65,7 +65,7 @@ void SpreadsheetsTest::compareExpectedDefinitionsOfOdsAndXlsx()
65
65
compareOdsAndXlsxExpectedData (Common::getDefinitionDumpSuffix ());
66
66
}
67
67
68
- void SpreadsheetsTest::compareExpectedTsvDumpsOfOdsAndXlsx_data ()
68
+ void SpreadsheetsTest::compareExpectedTsvDumpsOfOdsAndXlsx_data () const
69
69
{
70
70
addTestCaseForOdsAndXlsxComparison (QStringLiteral (" Compare tsv dumps" ));
71
71
}
@@ -76,7 +76,7 @@ void SpreadsheetsTest::compareExpectedTsvDumpsOfOdsAndXlsx()
76
76
}
77
77
78
78
void SpreadsheetsTest::addTestCaseForOdsAndXlsxComparison (
79
- const QString& testNamePrefix)
79
+ const QString& testNamePrefix) const
80
80
{
81
81
QTest::addColumn<QString>(" fileName" );
82
82
@@ -92,25 +92,30 @@ void SpreadsheetsTest::compareOdsAndXlsxExpectedData(const QString& fileSuffix)
92
92
QFETCH (const QString, fileName);
93
93
94
94
const QString filePath{Common::getSpreadsheetsDir () + fileName};
95
- auto [xlsxLoaded, xlsxDump] =
96
- file_utilities::loadFile (filePath + " .xlsx" + fileSuffix);
95
+ auto [xlsxLoaded,
96
+ xlsxDump]{ file_utilities::loadFile (filePath + " .xlsx" + fileSuffix)} ;
97
97
QVERIFY (xlsxLoaded);
98
98
99
- auto [odsLoaded, odsDump] =
100
- file_utilities::loadFile (filePath + " .ods" + fileSuffix);
99
+ auto [odsLoaded,
100
+ odsDump]{ file_utilities::loadFile (filePath + " .ods" + fileSuffix)} ;
101
101
QVERIFY (odsLoaded);
102
102
103
103
QStringList xlsxLines{xlsxDump.split (' \n ' )};
104
104
QStringList odsLines{odsDump.split (' \n ' )};
105
105
QCOMPARE (xlsxLines.size (), odsLines.size ());
106
- for (int i = 0 ; i < xlsxLines.size (); ++i)
107
- if (xlsxLines[i] != odsLines[i])
106
+
107
+ const qsizetype linesCount{xlsxLines.size ()};
108
+ for (int i{0 }; i < linesCount; ++i)
109
+ {
110
+ QString xlsxLine{xlsxLines[i]};
111
+ QString odsLine{odsLines[i]};
112
+ if (xlsxLine != odsLine)
108
113
{
109
114
const QString msg{" Difference in line " + QString::number (i + 1 ) +
110
- " \n Xlsx: " + xlsxLines[i] +
111
- " \n Ods : " + odsLines[i]};
115
+ " \n Xlsx: " + xlsxLine + " \n Ods : " + odsLine};
112
116
QFAIL (msg.toStdString ().c_str ());
113
117
}
118
+ }
114
119
}
115
120
116
121
void SpreadsheetsTest::addTestCasesForFileNames (
@@ -129,7 +134,7 @@ void SpreadsheetsTest::addTestCasesForFileNames(
129
134
}
130
135
}
131
136
132
- void SpreadsheetsTest::generateExpectedData ()
137
+ void SpreadsheetsTest::generateExpectedData () const
133
138
{
134
139
const QString generatedFilesDir{QApplication::applicationDirPath () +
135
140
" /generatedSpreadsheetsTestData/" };
0 commit comments