! * read from the beginning of the new data, read 1 sample, keep all data */
| 158 | * read from the beginning of the new data, read 1 sample, keep all data |
| 159 | */ |
| 160 | void LiveDataTest::testReadContinuousFixed01() { |
| 161 | // create a temp file and write some data into it |
| 162 | QTemporaryFile tempFile; |
| 163 | if (!tempFile.open()) |
| 164 | QFAIL("failed to create the temp file for writing"); |
| 165 | |
| 166 | QFile file(tempFile.fileName()); |
| 167 | if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) |
| 168 | QFAIL("failed to open the temp file for writing"); |
| 169 | |
| 170 | file.write("1,2\n3,4\n"); |
| 171 | file.flush(); |
| 172 | |
| 173 | // initialize the live data source |
| 174 | LiveDataSource dataSource(QStringLiteral("test"), false); |
| 175 | dataSource.setSourceType(LiveDataSource::SourceType::FileOrPipe); |
| 176 | dataSource.setFileType(AbstractFileFilter::FileType::Ascii); |
| 177 | dataSource.setFileName(file.fileName()); |
| 178 | dataSource.setReadingType(LiveDataSource::ReadingType::ContinuousFixed); |
| 179 | dataSource.setSampleSize(1); |
| 180 | dataSource.setUpdateType(LiveDataSource::UpdateType::NewData); |
| 181 | |
| 182 | // initialize the ASCII filter |
| 183 | auto* filter = new AsciiFilter(); |
| 184 | auto properties = filter->defaultProperties(); |
| 185 | properties.headerEnabled = false; |
| 186 | properties.intAsDouble = false; |
| 187 | properties.columnNamesRaw = QStringLiteral("x, y"); |
| 188 | properties.columnModesString = QStringLiteral("Int, Int"); |
| 189 | properties.automaticSeparatorDetection = false; |
| 190 | properties.separator = QStringLiteral(","); |
| 191 | QCOMPARE(filter->initialize(properties), AsciiFilter::Status::Success); |
| 192 | dataSource.setFilter(filter); |
| 193 | |
| 194 | // read the data and perform checks, after the initial read all data is read |
| 195 | dataSource.read(); |
| 196 | |
| 197 | QCOMPARE(dataSource.columnCount(), 2); |
| 198 | QCOMPARE(dataSource.rowCount(), 1); |
| 199 | |
| 200 | QCOMPARE(dataSource.column(0)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 201 | QCOMPARE(dataSource.column(1)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 202 | |
| 203 | QCOMPARE(dataSource.column(0)->integerAt(0), 1); |
| 204 | QCOMPARE(dataSource.column(1)->integerAt(0), 2); |
| 205 | |
| 206 | dataSource.read(); |
| 207 | |
| 208 | QCOMPARE(dataSource.columnCount(), 2); |
| 209 | QCOMPARE(dataSource.rowCount(), 2); |
| 210 | |
| 211 | QCOMPARE(dataSource.column(0)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 212 | QCOMPARE(dataSource.column(1)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 213 | |
| 214 | QCOMPARE(dataSource.column(0)->integerAt(0), 1); |
| 215 | QCOMPARE(dataSource.column(1)->integerAt(0), 2); |
| 216 | |
| 217 | QCOMPARE(dataSource.column(0)->integerAt(1), 3); |
nothing calls this directly
no test coverage detected