comparison data/fileio/test/CSVFormatTest.h @ 1585:9570ef94eaa3

Add mechanism to retrieve the set of plausible separators found in CSV-like file when guessing its format
author Chris Cannam
date Wed, 09 Jan 2019 14:39:50 +0000
parents a92e94215863
children 1b8c4ee06f6d
comparison
equal deleted inserted replaced
1578:07f23b90701a 1585:9570ef94eaa3
89 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-colon.csv"))); 89 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-colon.csv")));
90 QCOMPARE(f.getSeparator(), QChar(':')); 90 QCOMPARE(f.getSeparator(), QChar(':'));
91 QCOMPARE(f.getColumnCount(), 3); 91 QCOMPARE(f.getColumnCount(), 3);
92 } 92 }
93 93
94 void plausibleSeparators() {
95 CSVFormat f;
96 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-many.csv")));
97 std::set<QChar> p;
98 p.insert(QChar('|'));
99 p.insert(QChar(','));
100 p.insert(QChar(':'));
101 p.insert(QChar(' '));
102 std::set<QChar> actual = f.getPlausibleSeparators();
103 QCOMPARE(actual, p);
104 }
105
94 void comment() { 106 void comment() {
95 CSVFormat f; 107 CSVFormat f;
96 QVERIFY(f.guessFormatFor(csvDir.filePath("comment.csv"))); 108 QVERIFY(f.guessFormatFor(csvDir.filePath("comment.csv")));
97 QCOMPARE(f.getSeparator(), QChar(',')); 109 QCOMPARE(f.getSeparator(), QChar(','));
98 QCOMPARE(f.getColumnCount(), 4); 110 QCOMPARE(f.getColumnCount(), 4);