| 415 | } |
| 416 | |
| 417 | void TestWriter::testWriteDataContainCRLF() |
| 418 | { |
| 419 | QStringList firstLine = QStringList() << "one" << "two" << |
| 420 | "three\nfour,five"; |
| 421 | |
| 422 | QStringList secondLine = QStringList() << "six" << "seven,eight" << |
| 423 | "nine,\rten"; |
| 424 | |
| 425 | QtCSV::StringData strData; |
| 426 | strData.addRow(firstLine); |
| 427 | strData.addRow(secondLine); |
| 428 | |
| 429 | bool writeResult = QtCSV::Writer::write(getFilePath(), |
| 430 | strData, |
| 431 | ",", |
| 432 | QString()); |
| 433 | QVERIFY2(true == writeResult, "Failed to write to file"); |
| 434 | |
| 435 | QList<QStringList> data = QtCSV::Reader::readToList(getFilePath(), |
| 436 | ",", |
| 437 | "\""); |
| 438 | |
| 439 | QVERIFY2(false == data.isEmpty(), "Failed to read file content"); |
| 440 | QVERIFY2(2 == data.size(), "Wrong number of rows"); |
| 441 | QVERIFY2(firstLine == data.at(0), "Wrong data at first row"); |
| 442 | QVERIFY2(secondLine == data.at(1), "Wrong data at second row"); |
| 443 | } |