comparison base/test/TestStringBits.h @ 1524:64ef24ebb19c

Some CSV format tests and minor fixes
author Chris Cannam
date Fri, 14 Sep 2018 09:25:17 +0100
parents eecf544bed92
children bde22957545e
comparison
equal deleted inserted replaced
1523:c1b2eab6ac51 1524:64ef24ebb19c
126 QStringList out; 126 QStringList out;
127 out << "aa" << "bb cc\" dd"; 127 out << "aa" << "bb cc\" dd";
128 testSplitQuoted(in, out); 128 testSplitQuoted(in, out);
129 } 129 }
130 130
131 void snested3() {
132 QString in = "'aa bb cc\"' dd";
133 QStringList out;
134 out << "aa bb cc\"" << "dd";
135 testSplitQuoted(in, out);
136 }
137
138 void snested3a() {
139 QString in = "\"aa bb cc'\" dd";
140 QStringList out;
141 out << "aa bb cc'" << "dd";
142 testSplitQuoted(in, out);
143 }
144
145 void snested4() {
146 QString in = "'aa \"bb cc\" dd'";
147 QStringList out;
148 out << "aa \"bb cc\" dd";
149 testSplitQuoted(in, out);
150 }
151
152 void snested4a() {
153 QString in = "\"aa 'bb cc' dd\"";
154 QStringList out;
155 out << "aa 'bb cc' dd";
156 testSplitQuoted(in, out);
157 }
158
131 void qquoted() { 159 void qquoted() {
132 QString in = "a'a 'bb' \\\"cc\" dd\\\""; 160 QString in = "a'a 'bb' \\\"cc\" dd\\\"";
133 QStringList out; 161 QStringList out;
134 out << "a'a" << "bb" << "\"cc\"" << "dd\""; 162 out << "a'a" << "bb" << "\"cc\"" << "dd\"";
135 testSplitQuoted(in, out); 163 testSplitQuoted(in, out);
136 } 164 }
137 165
166 void qspace() {
167 QString in = "\"a a\":\"b:b\":\"c d\"";
168 QStringList out1;
169 // Can't start a quote in the middle of a bare field - they
170 // are handled only if the first character in the field is a
171 // quote. Otherwise we'd have trouble with apostrophes etc
172 out1 << "a a:\"b:b\":\"c" << "d\"";
173 QCOMPARE(StringBits::splitQuoted(in, ' '), out1);
174 QStringList out2;
175 out2 << "a a" << "b:b" << "c d";
176 QCOMPARE(StringBits::splitQuoted(in, ':'), out2);
177 }
178
138 void multispace() { 179 void multispace() {
139 QString in = " a'a \\' 'bb' ' \\\"cc\" ' dd\\\" '"; 180 QString in = " a'a \\' 'bb' ' \\\"cc\" ' dd\\\" '";
140 QStringList out; 181 QStringList out;
141 out << "a'a" << "'" << "bb" << " \"cc\" " << "dd\"" << "'"; 182 out << "a'a" << "'" << "bb" << " \"cc\" " << "dd\"" << "'";
142 QCOMPARE(StringBits::splitQuoted(in, ' '), out); 183 QCOMPARE(StringBits::splitQuoted(in, ' '), out);