MCPcopy Create free account
hub / github.com/KDE/labplot / testFullTableCustomRowRange

Method testFullTableCustomRowRange

tests/import_export/SQL/ImportSqlDatabaseTest.cpp:124–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void ImportSqlDatabaseTest::testFullTableCustomRowRange() {
125 // prepare the target spreadsheet
126 Spreadsheet spreadsheet(QStringLiteral("test"), false);
127
128 // import the records from 10 to 20 from the first table "artists"
129 ImportSQLDatabaseWidget w;
130 w.loadSettings();
131 w.setCustomQuery(false);
132 w.setStartRow(10);
133 w.setEndRow(20);
134 w.read(&spreadsheet, AbstractFileFilter::ImportMode::Replace);
135
136 // check the spreadsheet size and columns names and modes
137 QCOMPARE(spreadsheet.rowCount(), 11);
138 QCOMPARE(spreadsheet.columnCount(), 3);
139
140 QCOMPARE(spreadsheet.column(0)->name(), QLatin1String("AlbumId"));
141 QCOMPARE(spreadsheet.column(1)->name(), QLatin1String("Title"));
142 QCOMPARE(spreadsheet.column(2)->name(), QLatin1String("ArtistId"));
143
144 QCOMPARE(spreadsheet.column(0)->columnMode(), AbstractColumn::ColumnMode::Integer);
145 QCOMPARE(spreadsheet.column(1)->columnMode(), AbstractColumn::ColumnMode::Text);
146 QCOMPARE(spreadsheet.column(2)->columnMode(), AbstractColumn::ColumnMode::Integer);
147
148 // first row in the spreadsheet
149 QCOMPARE(spreadsheet.column(0)->integerAt(0), 10);
150 QCOMPARE(spreadsheet.column(1)->textAt(0), QLatin1String("Audioslave"));
151 QCOMPARE(spreadsheet.column(2)->integerAt(0), 8);
152
153 // last row in the spreadsheet
154 QCOMPARE(spreadsheet.column(0)->integerAt(10), 20);
155 QCOMPARE(spreadsheet.column(1)->textAt(10), QLatin1String("The Best Of Buddy Guy - The Millenium Collection"));
156 QCOMPARE(spreadsheet.column(2)->integerAt(10), 15);
157}
158
159/*!
160 * import the first two columns only

Callers

nothing calls this directly

Calls 12

setCustomQueryMethod · 0.80
loadSettingsMethod · 0.45
setStartRowMethod · 0.45
setEndRowMethod · 0.45
readMethod · 0.45
rowCountMethod · 0.45
columnCountMethod · 0.45
nameMethod · 0.45
columnMethod · 0.45
columnModeMethod · 0.45
integerAtMethod · 0.45
textAtMethod · 0.45

Tested by

no test coverage detected