File: | _build/../src/parser-test.cc |
Warning: | line 281, column 9 Value stored to 'buf' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * Copyright © 2017, 2018 Christian Persch |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 3 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #include "config.h" |
19 | |
20 | #include <string.h> |
21 | |
22 | #include <algorithm> |
23 | #include <cstddef> |
24 | #include <cstdint> |
25 | #include <string> |
26 | #include <vector> |
27 | |
28 | using namespace std::literals; |
29 | |
30 | #include <glib.h> |
31 | |
32 | #include "parser.hh" |
33 | #include "parser-glue.hh" |
34 | #include "parser-charset-tables.hh" |
35 | |
36 | #ifdef PARSER_INCLUDE_NOP1 |
37 | #define _BTE_NOP(...)_BTE_CMD(...) _BTE_CMD(__VA_ARGS__) |
38 | #define _BTE_NOQ(...)_BTE_SEQ(...) _BTE_SEQ(__VA_ARGS__) |
39 | #else |
40 | #define _BTE_NOP(...)_BTE_CMD(...) |
41 | #define _BTE_NOQ(...)_BTE_SEQ(...) |
42 | #endif |
43 | |
44 | using namespace bte::parser; |
45 | |
46 | Parser parser{}; |
47 | Sequence seq{parser}; |
48 | |
49 | #if 0 |
50 | static char const* |
51 | seq_to_str(unsigned int type) |
52 | { |
53 | switch (type) { |
54 | case BTE_SEQ_NONE: return "NONE"; |
55 | case BTE_SEQ_IGNORE: return "IGNORE"; |
56 | case BTE_SEQ_GRAPHIC: return "GRAPHIC"; |
57 | case BTE_SEQ_CONTROL: return "CONTROL"; |
58 | case BTE_SEQ_ESCAPE: return "ESCAPE"; |
59 | case BTE_SEQ_CSI: return "CSI"; |
60 | case BTE_SEQ_DCS: return "DCS"; |
61 | case BTE_SEQ_OSC: return "OSC"; |
62 | case BTE_SEQ_APC: return "APC"; |
63 | case BTE_SEQ_PM: return "PM"; |
64 | case BTE_SEQ_SOS: return "SOS"; |
65 | case BTE_SEQ_SCI: return "SCI"; |
66 | default: |
67 | g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "../src/parser-test.cc" , 67, ((const char*) (__PRETTY_FUNCTION__)), __null); } while (0); |
68 | } |
69 | } |
70 | |
71 | static char const* |
72 | cmd_to_str(unsigned int command) |
73 | { |
74 | switch (command) { |
75 | #define _BTE_CMD(cmd) case BTE_CMD_##cmd: return #cmd; |
76 | #include "parser-cmd.hh" |
77 | #undef _BTE_CMD |
78 | default: |
79 | static char buf[32]; |
80 | snprintf(buf, sizeof(buf), "UNKOWN(%u)", command); |
81 | return buf; |
82 | } |
83 | } |
84 | |
85 | static char const* |
86 | charset_to_str(unsigned int cs) |
87 | { |
88 | switch (cs) { |
89 | #define _BTE_CHARSET_PASTE(name) case BTE_CHARSET_##name: return #name; |
90 | #define _BTE_CHARSET(name) _BTE_CHARSET_PASTE(name) |
91 | #define _BTE_CHARSET_ALIAS_PASTE(name1,name2) |
92 | #define _BTE_CHARSET_ALIAS(name1,name2) |
93 | #include "parser-charset.hh" |
94 | #undef _BTE_CHARSET_PASTE |
95 | #undef _BTE_CHARSET |
96 | #undef _BTE_CHARSET_ALIAS_PASTE |
97 | #undef _BTE_CHARSET_ALIAS |
98 | default: |
99 | static char buf[32]; |
100 | snprintf(buf, sizeof(buf), "UNKOWN(%u)", cs); |
101 | return buf; |
102 | } |
103 | } |
104 | #endif |
105 | |
106 | static const char c0str[][6] = { |
107 | "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", |
108 | "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", |
109 | "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", |
110 | "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", |
111 | "SPACE" |
112 | }; |
113 | |
114 | static const char c1str[][5] = { |
115 | "DEL", |
116 | "0x80", "0x81", "BPH", "NBH", "0x84", "NEL", "SSA", "ESA", |
117 | "HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3", |
118 | "DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA", |
119 | "SOS", "0x99", "SCI", "CSI", "ST", "OSC", "PM", "APC" |
120 | }; |
121 | |
122 | static void |
123 | print_escaped(std::u32string const& s) |
124 | { |
125 | for (auto it : s) { |
126 | uint32_t c = (char32_t)it; |
127 | |
128 | if (c <= 0x20) |
129 | g_print("%s ", c0str[c]); |
130 | else if (c < 0x7f) |
131 | g_print("%c ", c); |
132 | else if (c < 0xa0) |
133 | g_print("%s ", c1str[c - 0x7f]); |
134 | else |
135 | g_print("U+%04X", c); |
136 | } |
137 | g_print("\n"); |
138 | } |
139 | |
140 | #if 0 |
141 | static void |
142 | print_seq() |
143 | { |
144 | auto c = seq.terminator(); |
145 | if (seq.command() == BTE_CMD_GRAPHIC) { |
146 | char buf[7]; |
147 | buf[g_unichar_to_utf8(c, buf)] = 0; |
148 | g_print("%s U+%04X [%s]\n", cmd_to_str(seq.command()), |
149 | c, |
150 | g_unichar_isprint(c) ? buf : "�"); |
151 | } else { |
152 | g_print("%s", cmd_to_str(seq.command())); |
153 | if (seq.size()) { |
154 | g_print(" "); |
155 | for (unsigned int i = 0; i < seq.size(); i++) { |
156 | if (i > 0) |
157 | g_print(";"); |
158 | g_print("%d", seq.param(i)); |
159 | } |
160 | } |
161 | g_print("\n"); |
162 | } |
163 | } |
164 | #endif |
165 | |
166 | class bte_seq_builder : public u32SequenceBuilder { |
167 | public: |
168 | bte_seq_builder(unsigned int type, |
169 | uint32_t f) |
170 | : u32SequenceBuilder(type, f) |
171 | { |
172 | } |
173 | |
174 | bte_seq_builder(unsigned int type, |
175 | u32SequenceBuilder::string_type const& str) |
176 | : u32SequenceBuilder(type) |
177 | { |
178 | set_string(str); |
179 | } |
180 | |
181 | void set_intermediates(uint32_t* i, |
182 | unsigned int ni) noexcept |
183 | { |
184 | for (unsigned int n = 0; n < ni; ++n) |
185 | append_intermediate(i[n]); |
186 | } |
187 | |
188 | |
189 | void set_params(int* params, |
190 | unsigned int n) noexcept |
191 | { |
192 | for (unsigned int i = 0; i < n; ++i) |
193 | append_param(params[i]); |
194 | } |
195 | |
196 | void print(bool c1 = false) const noexcept |
197 | { |
198 | std::u32string s; |
199 | to_string(s, c1); |
200 | print_escaped(s); |
201 | } |
202 | }; |
203 | |
204 | static int |
205 | feed_parser(std::u32string const& s) |
206 | { |
207 | int rv = BTE_SEQ_NONE; |
208 | for (auto it : s) { |
209 | rv = parser.feed((uint32_t)(char32_t)it); |
210 | if (rv < 0) |
211 | break; |
212 | } |
213 | return rv; |
214 | } |
215 | |
216 | static int |
217 | feed_parser(bte_seq_builder& b, |
218 | bool c1 = false) |
219 | { |
220 | std::u32string s; |
221 | b.to_string(s, c1); |
222 | |
223 | return feed_parser(s); |
224 | } |
225 | |
226 | static void |
227 | test_seq_arg(void) |
228 | { |
229 | /* Basic test */ |
230 | bte_seq_arg_t arg = BTE_SEQ_ARG_INIT_DEFAULT(0); |
231 | g_assert_false(bte_seq_arg_started(arg))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_170 ; if (!(bte_seq_arg_started(arg))) _g_boolean_var_170 = 1; else _g_boolean_var_170 = 0; _g_boolean_var_170; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 231, ((const char*) ( __PRETTY_FUNCTION__)), "'" "bte_seq_arg_started(arg)" "' should be FALSE" ); } while (0); |
232 | g_assert_true(bte_seq_arg_default(arg))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_171 ; if (bte_seq_arg_default(arg)) _g_boolean_var_171 = 1; else _g_boolean_var_171 = 0; _g_boolean_var_171; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 232, ((const char*) (__PRETTY_FUNCTION__ )), "'" "bte_seq_arg_default(arg)" "' should be TRUE"); } while (0); |
233 | |
234 | bte_seq_arg_push(&arg, '1'); |
235 | bte_seq_arg_push(&arg, '2'); |
236 | bte_seq_arg_push(&arg, '3'); |
237 | bte_seq_arg_finish(&arg); |
238 | |
239 | g_assert_cmpint(bte_seq_arg_value(arg), ==, 123)do { gint64 __n1 = (bte_seq_arg_value(arg)), __n2 = (123); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0 ), "../src/parser-test.cc", 239, ((const char*) (__PRETTY_FUNCTION__ )), "bte_seq_arg_value(arg)" " " "==" " " "123", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
240 | g_assert_false(bte_seq_arg_default(arg))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_172 ; if (!(bte_seq_arg_default(arg))) _g_boolean_var_172 = 1; else _g_boolean_var_172 = 0; _g_boolean_var_172; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 240, ((const char*) ( __PRETTY_FUNCTION__)), "'" "bte_seq_arg_default(arg)" "' should be FALSE" ); } while (0); |
241 | |
242 | /* Test max value */ |
243 | arg = BTE_SEQ_ARG_INIT_DEFAULT(0); |
244 | bte_seq_arg_push(&arg, '6'); |
245 | bte_seq_arg_push(&arg, '5'); |
246 | bte_seq_arg_push(&arg, '5'); |
247 | bte_seq_arg_push(&arg, '3'); |
248 | bte_seq_arg_push(&arg, '6'); |
249 | bte_seq_arg_finish(&arg); |
250 | |
251 | g_assert_cmpint(bte_seq_arg_value(arg), ==, 65535)do { gint64 __n1 = (bte_seq_arg_value(arg)), __n2 = (65535); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0 ), "../src/parser-test.cc", 251, ((const char*) (__PRETTY_FUNCTION__ )), "bte_seq_arg_value(arg)" " " "==" " " "65535", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
252 | } |
253 | |
254 | static void |
255 | test_seq_string(void) |
256 | { |
257 | bte_seq_string_t str; |
258 | bte_seq_string_init(&str); |
259 | |
260 | size_t len; |
261 | auto buf = bte_seq_string_get(&str, &len); |
262 | g_assert_cmpuint(len, ==, 0)do { guint64 __n1 = (len), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 262, ((const char*) (__PRETTY_FUNCTION__)), "len" " " "==" " " "0", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
263 | |
264 | for (unsigned int i = 0; i < BTE_SEQ_STRING_MAX_CAPACITY(1 << 12); ++i) { |
265 | auto rv = bte_seq_string_push(&str, 0xfffdU); |
266 | g_assert_true(rv)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_173 ; if (rv) _g_boolean_var_173 = 1; else _g_boolean_var_173 = 0 ; _g_boolean_var_173; }), 1)) ; else g_assertion_message (((gchar *) 0), "../src/parser-test.cc", 266, ((const char*) (__PRETTY_FUNCTION__ )), "'" "rv" "' should be TRUE"); } while (0); |
267 | |
268 | buf = bte_seq_string_get(&str, &len); |
269 | g_assert_cmpuint(len, ==, i + 1)do { guint64 __n1 = (len), __n2 = (i + 1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 269, ((const char*) (__PRETTY_FUNCTION__)), "len" " " "==" " " "i + 1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
270 | } |
271 | |
272 | /* Try one more */ |
273 | auto rv = bte_seq_string_push(&str, 0xfffdU); |
274 | g_assert_false(rv)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_174 ; if (!(rv)) _g_boolean_var_174 = 1; else _g_boolean_var_174 = 0; _g_boolean_var_174; }), 1)) ; else g_assertion_message (( (gchar*) 0), "../src/parser-test.cc", 274, ((const char*) (__PRETTY_FUNCTION__ )), "'" "rv" "' should be FALSE"); } while (0); |
275 | |
276 | buf = bte_seq_string_get(&str, &len); |
277 | for (unsigned int i = 0; i < len; i++) |
278 | g_assert_cmpuint(buf[i], ==, 0xfffdU)do { guint64 __n1 = (buf[i]), __n2 = (0xfffdU); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 278, ((const char*) (__PRETTY_FUNCTION__)), "buf[i]" " " "==" " " "0xfffdU", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
279 | |
280 | bte_seq_string_reset(&str); |
281 | buf = bte_seq_string_get(&str, &len); |
Value stored to 'buf' is never read | |
282 | g_assert_cmpuint(len, ==, 0)do { guint64 __n1 = (len), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 282, ((const char*) (__PRETTY_FUNCTION__)), "len" " " "==" " " "0", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
283 | |
284 | bte_seq_string_free(&str); |
285 | } |
286 | |
287 | static void |
288 | test_seq_control(void) |
289 | { |
290 | static struct { |
291 | uint32_t c; |
292 | unsigned int cmd; |
293 | } const controls [] = { |
294 | #define _BTE_SEQ(cmd,type,f,pi,ni,i0) { f, BTE_CMD_##cmd }, |
295 | #include "parser-c01.hh" |
296 | #undef _BTE_SEQ |
297 | }; |
298 | |
299 | for (unsigned int i = 0; i < G_N_ELEMENTS(controls)(sizeof (controls) / sizeof ((controls)[0])); i++) { |
300 | parser.reset(); |
301 | auto rv = parser.feed(controls[i].c); |
302 | g_assert_cmpuint(rv, ==, BTE_SEQ_CONTROL)do { guint64 __n1 = (rv), __n2 = (BTE_SEQ_CONTROL); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 302, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_CONTROL", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
303 | g_assert_cmpuint(controls[i].cmd, ==, seq.command())do { guint64 __n1 = (controls[i].cmd), __n2 = (seq.command()) ; if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 303, ((const char*) (__PRETTY_FUNCTION__ )), "controls[i].cmd" " " "==" " " "seq.command()", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
304 | } |
305 | } |
306 | |
307 | static void |
308 | test_seq_esc_invalid(void) |
309 | { |
310 | /* Tests invalid ESC 0/n and ESC 1/n sequences, which should never result in |
311 | * an BTE_SEQ_ESCAPE type sequence, but instead always in the C0 control. |
312 | */ |
313 | for (uint32_t f = 0x0; f < 0x20; f++) { |
314 | parser.reset(); |
315 | |
316 | bte_seq_builder b{BTE_SEQ_ESCAPE, f}; |
317 | auto rv = feed_parser(b); |
318 | g_assert_cmpint(rv, !=, BTE_SEQ_ESCAPE)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_ESCAPE); if (__n1 != __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 318, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "!=" " " "BTE_SEQ_ESCAPE", (long double) __n1, "!=", (long double) __n2 , 'i'); } while (0); |
319 | } |
320 | } |
321 | |
322 | static void |
323 | test_seq_esc(uint32_t f, |
324 | uint32_t i[], |
325 | unsigned int ni) |
326 | { |
327 | bte_seq_builder b{BTE_SEQ_ESCAPE, f}; |
328 | b.set_intermediates(i, ni); |
329 | |
330 | parser.reset(); |
331 | auto rv = feed_parser(b); |
332 | if (rv != BTE_SEQ_ESCAPE) |
333 | return; |
334 | |
335 | b.assert_equal(seq); |
336 | } |
337 | |
338 | static void |
339 | test_seq_esc_nF(void) |
340 | { |
341 | /* Tests nF sequences, that is ESC 2/n [2/m..] F with F being 3/0..7/14. |
342 | * They could have any number of itermediates, but we only test up to 4. |
343 | */ |
344 | |
345 | uint32_t i[4]; |
346 | for (uint32_t f = 0x30; f < 0x7f; f++) { |
347 | test_seq_esc(f, i, 0); |
348 | for (i[0] = 0x20; i[0] < 0x30; i[0]++) { |
349 | test_seq_esc(f, i, 1); |
350 | for (i[1] = 0x20; i[1] < 0x30; i[1]++) { |
351 | test_seq_esc(f, i, 2); |
352 | for (i[2] = 0x20; i[2] < 0x30; i[2]++) { |
353 | test_seq_esc(f, i, 3); |
354 | for (i[3] = 0x20; i[3] < 0x30; i[3]++) { |
355 | test_seq_esc(f, i, 4); |
356 | } |
357 | } |
358 | } |
359 | } |
360 | } |
361 | } |
362 | |
363 | static void |
364 | test_seq_esc_charset(uint32_t f, /* final */ |
365 | uint32_t i[], /* intermediates */ |
366 | unsigned int ni, /* number of intermediates */ |
367 | unsigned int cmd, /* expected command */ |
368 | unsigned int cs /* expected charset */, |
369 | unsigned int slot /* expected slot */) |
370 | { |
371 | bte_seq_builder b{BTE_SEQ_ESCAPE, f}; |
372 | b.set_intermediates(i, ni); |
373 | |
374 | parser.reset(); |
375 | auto rv = feed_parser(b); |
376 | g_assert_cmpint(rv, ==, BTE_SEQ_ESCAPE)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_ESCAPE); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 376, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_ESCAPE", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
377 | b.assert_equal(seq); |
378 | |
379 | g_assert_cmpint(seq.command(), ==, cmd)do { gint64 __n1 = (seq.command()), __n2 = (cmd); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 379, ((const char*) (__PRETTY_FUNCTION__)), "seq.command()" " " "==" " " "cmd", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
380 | g_assert_cmpint(seq.charset(), ==, cs)do { gint64 __n1 = (seq.charset()), __n2 = (cs); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 380, ((const char*) (__PRETTY_FUNCTION__)), "seq.charset()" " " "==" " " "cs", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
381 | g_assert_cmpint(seq.slot(), ==, slot)do { gint64 __n1 = (seq.slot()), __n2 = (slot); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 381, ((const char*) (__PRETTY_FUNCTION__)), "seq.slot()" " " "==" " " "slot", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
382 | } |
383 | |
384 | static void |
385 | test_seq_esc_charset(uint32_t i[], /* intermediates */ |
386 | unsigned int ni, /* number of intermediates */ |
387 | uint8_t const* const table, /* table */ |
388 | unsigned int ntable, /* number of table entries */ |
389 | uint32_t ts, /* start of table */ |
390 | unsigned int cmd, /* expected command */ |
391 | unsigned int defaultcs /* default charset */, |
392 | unsigned int slot /* expected slot */) |
393 | { |
394 | for (uint32_t f = 0x30; f < 0x7f; f++) { |
395 | int cs; |
396 | |
397 | if (f >= ts && f < (ts + ntable)) |
398 | cs = table[f - ts]; |
399 | else |
400 | cs = defaultcs; |
401 | |
402 | test_seq_esc_charset(f, i, ni, cmd, cs, slot); |
403 | } |
404 | } |
405 | |
406 | static void |
407 | test_seq_esc_charset_94(void) |
408 | { |
409 | uint32_t i[4]; |
410 | |
411 | /* Single byte 94-sets */ |
412 | for (i[0] = 0x28; i[0] <= 0x2b; i[0]++) { |
413 | int slot = i[0] - 0x28; |
414 | |
415 | test_seq_esc_charset(i, 1, |
416 | charset_graphic_94, |
417 | G_N_ELEMENTS(charset_graphic_94)(sizeof (charset_graphic_94) / sizeof ((charset_graphic_94)[0 ])), |
418 | 0x30, BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
419 | |
420 | i[1] = 0x20; |
421 | test_seq_esc_charset(i, 2, nullptr, 0, 0, |
422 | BTE_CMD_GnDm, BTE_CHARSET_DRCS, slot); |
423 | |
424 | i[1] = 0x21; |
425 | test_seq_esc_charset(i, 2, |
426 | charset_graphic_94_with_2_1, |
427 | G_N_ELEMENTS(charset_graphic_94_with_2_1)(sizeof (charset_graphic_94_with_2_1) / sizeof ((charset_graphic_94_with_2_1 )[0])), |
428 | 0x40, BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
429 | |
430 | i[1] = 0x22; |
431 | test_seq_esc_charset(i, 2, |
432 | charset_graphic_94_with_2_2, |
433 | G_N_ELEMENTS(charset_graphic_94_with_2_2)(sizeof (charset_graphic_94_with_2_2) / sizeof ((charset_graphic_94_with_2_2 )[0])), |
434 | 0x30, BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
435 | |
436 | i[1] = 0x23; |
437 | test_seq_esc_charset(i, 2, nullptr, 0, |
438 | 0x30, BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
439 | |
440 | /* 2/4 is multibyte charsets */ |
441 | |
442 | i[1] = 0x25; |
443 | test_seq_esc_charset(i, 2, |
444 | charset_graphic_94_with_2_5, |
445 | G_N_ELEMENTS(charset_graphic_94_with_2_5)(sizeof (charset_graphic_94_with_2_5) / sizeof ((charset_graphic_94_with_2_5 )[0])), |
446 | 0x30, BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
447 | |
448 | i[1] = 0x26; |
449 | test_seq_esc_charset(i, 2, |
450 | charset_graphic_94_with_2_6, |
451 | G_N_ELEMENTS(charset_graphic_94_with_2_6)(sizeof (charset_graphic_94_with_2_6) / sizeof ((charset_graphic_94_with_2_6 )[0])), |
452 | 0x30, BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
453 | |
454 | i[1] = 0x27; |
455 | test_seq_esc_charset(i, 2, nullptr, 0, 0, |
456 | BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
457 | } |
458 | } |
459 | |
460 | static void |
461 | test_seq_esc_charset_96(void) |
462 | { |
463 | uint32_t i[4]; |
464 | |
465 | /* Single byte 96-sets */ |
466 | for (i[0] = 0x2d; i[0] <= 0x2f; i[0]++) { |
467 | int slot = i[0] - 0x2c; |
468 | |
469 | test_seq_esc_charset(i, 1, |
470 | charset_graphic_96, |
471 | G_N_ELEMENTS(charset_graphic_96)(sizeof (charset_graphic_96) / sizeof ((charset_graphic_96)[0 ])), |
472 | 0x30, BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
473 | |
474 | i[1] = 0x20; |
475 | test_seq_esc_charset(i, 2, nullptr, 0, 0, |
476 | BTE_CMD_GnDm, BTE_CHARSET_DRCS, slot); |
477 | |
478 | /* 2/4 is multibyte charsets, 2/5 is DOCS. Other indermediates may be present |
479 | * in Fp sequences, but none are actually in use. |
480 | */ |
481 | for (i[1] = 0x21; i[1] < 0x28; i[1]++) { |
482 | if (i[1] == 0x24 || i[1] == 0x25) |
483 | continue; |
484 | |
485 | test_seq_esc_charset(i, 2, nullptr, 0, 0, |
486 | BTE_CMD_GnDm, BTE_CHARSET_NONE, slot); |
487 | } |
488 | } |
489 | } |
490 | |
491 | static void |
492 | test_seq_esc_charset_94_n(void) |
493 | { |
494 | uint32_t i[4]; |
495 | |
496 | /* Multibyte 94-sets */ |
497 | i[0] = 0x24; |
498 | for (i[1] = 0x28; i[1] <= 0x2b; i[1]++) { |
499 | int slot = i[1] - 0x28; |
500 | |
501 | test_seq_esc_charset(i, 2, |
502 | charset_graphic_94_n, |
503 | G_N_ELEMENTS(charset_graphic_94_n)(sizeof (charset_graphic_94_n) / sizeof ((charset_graphic_94_n )[0])), |
504 | 0x30, BTE_CMD_GnDMm, BTE_CHARSET_NONE, slot); |
505 | |
506 | i[2] = 0x20; |
507 | test_seq_esc_charset(i, 3, nullptr, 0, 0, |
508 | BTE_CMD_GnDMm, BTE_CHARSET_DRCS, slot); |
509 | |
510 | /* There could be one more intermediate byte. */ |
511 | for (i[2] = 0x21; i[2] < 0x28; i[2]++) { |
512 | if (i[2] == 0x24) /* TODO */ |
513 | continue; |
514 | |
515 | test_seq_esc_charset(i, 3, nullptr, 0, 0, |
516 | BTE_CMD_GnDMm, BTE_CHARSET_NONE, slot); |
517 | } |
518 | } |
519 | |
520 | /* As a special exception, ESC 2/4 4/[012] are also possible */ |
521 | test_seq_esc_charset(0x40, i, 1, BTE_CMD_GnDMm, charset_graphic_94_n[0x40 - 0x30], 0); |
522 | test_seq_esc_charset(0x41, i, 1, BTE_CMD_GnDMm, charset_graphic_94_n[0x41 - 0x30], 0); |
523 | test_seq_esc_charset(0x42, i, 1, BTE_CMD_GnDMm, charset_graphic_94_n[0x42 - 0x30], 0); |
524 | } |
525 | |
526 | static void |
527 | test_seq_esc_charset_96_n(void) |
528 | { |
529 | uint32_t i[4]; |
530 | |
531 | /* Multibyte 94-sets */ |
532 | i[0] = 0x24; |
533 | for (i[1] = 0x2d; i[1] <= 0x2f; i[1]++) { |
534 | int slot = i[1] - 0x2c; |
535 | |
536 | test_seq_esc_charset(i, 2, nullptr, 0, 0, |
537 | BTE_CMD_GnDMm, BTE_CHARSET_NONE, slot); |
538 | |
539 | i[2] = 0x20; |
540 | test_seq_esc_charset(i, 3, nullptr, 0, 0, |
541 | BTE_CMD_GnDMm, BTE_CHARSET_DRCS, slot); |
542 | |
543 | /* There could be one more intermediate byte. */ |
544 | for (i[2] = 0x21; i[2] < 0x28; i[2]++) { |
545 | test_seq_esc_charset(i, 3, nullptr, 0, 0, |
546 | BTE_CMD_GnDMm, BTE_CHARSET_NONE, slot); |
547 | } |
548 | } |
549 | } |
550 | |
551 | static void |
552 | test_seq_esc_charset_control(void) |
553 | { |
554 | uint32_t i[4]; |
555 | |
556 | /* C0 controls: ESC 2/1 F */ |
557 | i[0] = 0x21; |
558 | test_seq_esc_charset(i, 1, |
559 | charset_control_c0, |
560 | G_N_ELEMENTS(charset_control_c0)(sizeof (charset_control_c0) / sizeof ((charset_control_c0)[0 ])), |
561 | 0x40, BTE_CMD_CnD, BTE_CHARSET_NONE, 0); |
562 | |
563 | /* C1 controls: ESC 2/2 F */ |
564 | i[0] = 0x22; |
565 | test_seq_esc_charset(i, 1, |
566 | charset_control_c1, |
567 | G_N_ELEMENTS(charset_control_c1)(sizeof (charset_control_c1) / sizeof ((charset_control_c1)[0 ])), |
568 | 0x40, BTE_CMD_CnD, BTE_CHARSET_NONE, 1); |
569 | } |
570 | |
571 | static void |
572 | test_seq_esc_charset_other(void) |
573 | { |
574 | uint32_t i[4]; |
575 | |
576 | /* Other coding systems: ESC 2/5 F or ESC 2/5 I F */ |
577 | i[0] = 0x25; |
578 | test_seq_esc_charset(i, 1, |
579 | charset_ocs, |
580 | G_N_ELEMENTS(charset_ocs)(sizeof (charset_ocs) / sizeof ((charset_ocs)[0])), |
581 | 0x30, BTE_CMD_DOCS, BTE_CHARSET_NONE, 0); |
582 | |
583 | i[1] = 0x20; |
584 | test_seq_esc_charset(i, 2, |
585 | charset_ocs_with_2_0, |
586 | G_N_ELEMENTS(charset_ocs_with_2_0)(sizeof (charset_ocs_with_2_0) / sizeof ((charset_ocs_with_2_0 )[0])), |
587 | 0x30, BTE_CMD_DOCS, BTE_CHARSET_NONE, 0); |
588 | |
589 | i[1] = 0x2f; |
590 | test_seq_esc_charset(i, 2, |
591 | charset_ocs_with_2_15, |
592 | G_N_ELEMENTS(charset_ocs_with_2_15)(sizeof (charset_ocs_with_2_15) / sizeof ((charset_ocs_with_2_15 )[0])), |
593 | 0x40, BTE_CMD_DOCS, BTE_CHARSET_NONE, 0); |
594 | } |
595 | |
596 | static void |
597 | test_seq_esc_Fpes(void) |
598 | { |
599 | /* Tests Fp, Fe and Ft sequences, that is ESC 3/n .. ESC 7/14 */ |
600 | |
601 | for (uint32_t f = 0x30; f < 0x7f; f++) { |
602 | parser.reset(); |
603 | |
604 | bte_seq_builder b{BTE_SEQ_ESCAPE, f}; |
605 | |
606 | auto rv = feed_parser(b); |
607 | int expected_rv; |
608 | switch (f) { |
609 | case 'P': /* DCS */ |
610 | case 'X': /* SOS */ |
611 | case 'Z': /* SCI */ |
612 | case '_': /* APC */ |
613 | case '[': /* CSI */ |
614 | case ']': /* OSC */ |
615 | case '^': /* PM */ |
616 | expected_rv = BTE_SEQ_NONE; |
617 | break; |
618 | default: |
619 | expected_rv = BTE_SEQ_ESCAPE; |
620 | break; |
621 | } |
622 | g_assert_cmpint(rv, ==, expected_rv)do { gint64 __n1 = (rv), __n2 = (expected_rv); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 622, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "expected_rv", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
623 | if (rv != BTE_SEQ_NONE) |
624 | b.assert_equal(seq); |
625 | } |
626 | } |
627 | |
628 | static void |
629 | test_seq_esc_known(uint32_t f, |
630 | uint32_t i, |
631 | unsigned int cmd) |
632 | { |
633 | bte_seq_builder b{BTE_SEQ_ESCAPE, f}; |
634 | if (i != 0) |
635 | b.set_intermediates(&i, 1); |
636 | |
637 | auto rv = feed_parser(b); |
638 | g_assert_cmpint(rv, ==, BTE_SEQ_ESCAPE)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_ESCAPE); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 638, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_ESCAPE", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
639 | g_assert_cmpint(seq.command(), ==, cmd)do { gint64 __n1 = (seq.command()), __n2 = (cmd); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 639, ((const char*) (__PRETTY_FUNCTION__)), "seq.command()" " " "==" " " "cmd", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
640 | } |
641 | |
642 | static void |
643 | test_seq_esc_known(void) |
644 | { |
645 | parser.reset(); |
646 | |
647 | #define _BTE_SEQ(cmd,type,f,p,ni,i) \ |
648 | test_seq_esc_known(f, BTE_SEQ_INTERMEDIATE_CHAR_##i, BTE_CMD_##cmd); |
649 | #include "parser-esc.hh" |
650 | #undef _BTE_SEQ |
651 | } |
652 | |
653 | static void |
654 | test_seq_csi(uint32_t f, |
655 | uint32_t p, |
656 | bte_seq_arg_t params[16], |
657 | uint32_t i[4], |
658 | unsigned int ni) |
659 | { |
660 | bte_seq_builder b{BTE_SEQ_CSI, f}; |
661 | b.set_intermediates(i, ni); |
662 | b.set_param_intro(p); |
663 | |
664 | int expected_rv = (f & 0xF0) == 0x30 ? BTE_SEQ_NONE : BTE_SEQ_CSI; |
665 | |
666 | for (unsigned int n = 0; n <= 16; n++) { |
667 | b.reset_params(); |
668 | b.set_params(params, n); |
669 | |
670 | parser.reset(); |
671 | /* First with C0 CSI */ |
672 | auto rv = feed_parser(b, false); |
673 | g_assert_cmpint(rv, ==, expected_rv)do { gint64 __n1 = (rv), __n2 = (expected_rv); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 673, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "expected_rv", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
674 | if (rv != BTE_SEQ_NONE) |
675 | b.assert_equal_full(seq); |
676 | |
677 | /* Now with C1 CSI */ |
678 | rv = feed_parser(b, true); |
679 | if (rv != BTE_SEQ_NONE) |
680 | b.assert_equal_full(seq); |
681 | } |
682 | } |
683 | |
684 | static void |
685 | test_seq_csi(uint32_t p, |
686 | bte_seq_arg_t params[16]) |
687 | { |
688 | uint32_t i[4]; |
689 | for (uint32_t f = 0x30; f < 0x7f; f++) { |
690 | test_seq_csi(f, p, params, i, 0); |
691 | for (i[0] = 0x20; i[0] < 0x30; i[0]++) { |
692 | test_seq_csi(f, p, params, i, 1); |
693 | for (i[1] = 0x20; i[1] < 0x30; i[1]++) { |
694 | test_seq_csi(f, p, params, i, 2); |
695 | } |
696 | } |
697 | } |
698 | } |
699 | |
700 | static void |
701 | test_seq_csi(bte_seq_arg_t params[16]) |
702 | { |
703 | test_seq_csi(0, params); |
704 | for (uint32_t p = 0x3c; p <= 0x3f; p++) |
705 | test_seq_csi(p, params); |
706 | } |
707 | |
708 | static void |
709 | test_seq_csi(void) |
710 | { |
711 | /* Tests CSI sequences, that is sequences of the form |
712 | * CSI P...P I...I F |
713 | * with parameter bytes P from 3/0..3/15, intermediate bytes I from 2/0..2/15 and |
714 | * final byte F from 4/0..7/14. |
715 | * There could be any number of intermediate bytes, but we only test up to 2. |
716 | * There could be any number of extra params bytes, but we only test up to 1. |
717 | * CSI can be either the C1 control itself, or ESC [ |
718 | */ |
719 | bte_seq_arg_t params1[16]{ -1, 0, 1, 9, 10, 99, 100, 999, |
720 | 1000, 9999, 10000, 65534, 65535, 65536, -1, -1 }; |
721 | test_seq_csi(params1); |
722 | |
723 | bte_seq_arg_t params2[16]{ 1, -1, -1, -1, 1, -1, 1, 1, |
724 | 1, -1, -1, -1, -1, 1, 1, 1 }; |
725 | test_seq_csi(params2); |
726 | } |
727 | |
728 | static void |
729 | test_seq_sci(uint32_t f, |
730 | bool valid) |
731 | { |
732 | bte_seq_builder b{BTE_SEQ_SCI, f}; |
733 | |
734 | /* First with C0 SCI */ |
735 | auto rv = feed_parser(b, false); |
736 | if (valid) { |
737 | g_assert_cmpint(rv, ==, BTE_SEQ_SCI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_SCI); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 737, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_SCI", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
738 | b.assert_equal_full(seq); |
739 | } else |
740 | g_assert_cmpint(rv, !=, BTE_SEQ_SCI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_SCI); if (__n1 != __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 740, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "!=" " " "BTE_SEQ_SCI", (long double) __n1, "!=", (long double) __n2, 'i'); } while (0); |
741 | |
742 | /* Now with C1 SCI */ |
743 | rv = feed_parser(b, true); |
744 | if (valid) { |
745 | g_assert_cmpint(rv, ==, BTE_SEQ_SCI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_SCI); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 745, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_SCI", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
746 | b.assert_equal_full(seq); |
747 | } else |
748 | g_assert_cmpint(rv, !=, BTE_SEQ_SCI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_SCI); if (__n1 != __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 748, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "!=" " " "BTE_SEQ_SCI", (long double) __n1, "!=", (long double) __n2, 'i'); } while (0); |
749 | } |
750 | |
751 | static void |
752 | test_seq_sci(void) |
753 | { |
754 | /* Tests SCI sequences, that is sequences of the form SCI F |
755 | * with final byte 0/8..0/13 or 2/0..7/14 |
756 | * SCI can be either the C1 control itself, or ESC Z |
757 | */ |
758 | parser.reset(); |
759 | |
760 | for (uint32_t f = 0x8; f <= 0xd; ++f) |
761 | test_seq_sci(f, true); |
762 | for (uint32_t f = 0x20; f <= 0x7e; ++f) |
763 | test_seq_sci(f, true); |
764 | for (uint32_t f = 0x7f; f <= 0xff; ++f) |
765 | test_seq_sci(f, false); |
766 | } |
767 | |
768 | G_GNUC_UNUSED__attribute__ ((__unused__)) |
769 | static void |
770 | test_seq_sci_known(uint32_t f, |
771 | unsigned int cmd) |
772 | { |
773 | bte_seq_builder b{BTE_SEQ_SCI, f}; |
774 | |
775 | auto rv = feed_parser(b); |
776 | g_assert_cmpint(rv, ==, BTE_SEQ_SCI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_SCI); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 776, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_SCI", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
777 | g_assert_cmpint(seq.command(), ==, cmd)do { gint64 __n1 = (seq.command()), __n2 = (cmd); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 777, ((const char*) (__PRETTY_FUNCTION__)), "seq.command()" " " "==" " " "cmd", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
778 | } |
779 | |
780 | static void |
781 | test_seq_sci_known(void) |
782 | { |
783 | parser.reset(); |
784 | |
785 | #define _BTE_SEQ(cmd,type,f,p,ni,i) \ |
786 | test_seq_sci_known(f, BTE_CMD_##cmd); |
787 | #include "parser-sci.hh" |
788 | #undef _BTE_SEQ |
789 | } |
790 | |
791 | static void |
792 | test_seq_csi_known(uint32_t f, |
793 | uint32_t p, |
794 | uint32_t i, |
795 | unsigned int cmd) |
796 | { |
797 | bte_seq_builder b{BTE_SEQ_CSI, f}; |
798 | if (p != 0) |
799 | b.set_param_intro(p); |
800 | if (i != 0) |
801 | b.set_intermediates(&i, 1); |
802 | |
803 | auto rv = feed_parser(b); |
804 | g_assert_cmpint(rv, ==, BTE_SEQ_CSI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_CSI); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 804, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_CSI", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
805 | g_assert_cmpint(seq.command(), ==, cmd)do { gint64 __n1 = (seq.command()), __n2 = (cmd); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 805, ((const char*) (__PRETTY_FUNCTION__)), "seq.command()" " " "==" " " "cmd", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
806 | } |
807 | |
808 | static void |
809 | test_seq_csi_known(void) |
810 | { |
811 | parser.reset(); |
812 | |
813 | #define _BTE_SEQ(cmd,type,f,p,ni,i) \ |
814 | test_seq_csi_known(f, BTE_SEQ_PARAMETER_CHAR_##p, BTE_SEQ_INTERMEDIATE_CHAR_##i, BTE_CMD_##cmd); |
815 | #include "parser-csi.hh" |
816 | #undef _BTE_SEQ |
817 | } |
818 | |
819 | static void |
820 | test_seq_dcs(uint32_t f, |
821 | uint32_t p, |
822 | bte_seq_arg_t params[16], |
823 | uint32_t i[4], |
824 | unsigned int ni, |
825 | std::u32string const& str, |
826 | int expected_rv = BTE_SEQ_DCS) |
827 | { |
828 | bte_seq_builder b{BTE_SEQ_DCS, f}; |
829 | b.set_intermediates(i, ni); |
830 | b.set_param_intro(p); |
831 | b.set_string(str); |
832 | |
833 | int expected_rv0 = (f & 0xF0) == 0x30 || expected_rv == BTE_SEQ_NONE ? BTE_SEQ_ESCAPE /* the C0 ST */ : expected_rv; |
834 | int expected_rv1 = (f & 0xF0) == 0x30 ? BTE_SEQ_NONE : expected_rv; |
835 | |
836 | for (unsigned int n = 0; n <= 16; n++) { |
837 | b.reset_params(); |
838 | b.set_params(params, n); |
839 | |
840 | parser.reset(); |
841 | |
842 | /* First with C0 DCS */ |
843 | auto rv0 = feed_parser(b, false); |
844 | g_assert_cmpint(rv0, ==, expected_rv0)do { gint64 __n1 = (rv0), __n2 = (expected_rv0); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 844, ((const char*) (__PRETTY_FUNCTION__)), "rv0" " " "==" " " "expected_rv0", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
845 | if (rv0 != BTE_SEQ_ESCAPE && rv0 != BTE_SEQ_NONE) |
846 | b.assert_equal_full(seq); |
847 | if (rv0 == BTE_SEQ_ESCAPE) |
848 | g_assert_cmpint(seq.command(), ==, BTE_CMD_ST)do { gint64 __n1 = (seq.command()), __n2 = (BTE_CMD_ST); if ( __n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0) , "../src/parser-test.cc", 848, ((const char*) (__PRETTY_FUNCTION__ )), "seq.command()" " " "==" " " "BTE_CMD_ST", (long double) __n1 , "==", (long double) __n2, 'i'); } while (0); |
849 | |
850 | /* Now with C1 DCS */ |
851 | auto rv1 = feed_parser(b, true); |
852 | g_assert_cmpint(rv1, ==, expected_rv1)do { gint64 __n1 = (rv1), __n2 = (expected_rv1); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 852, ((const char*) (__PRETTY_FUNCTION__)), "rv1" " " "==" " " "expected_rv1", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
853 | if (rv1 != BTE_SEQ_NONE) |
854 | b.assert_equal_full(seq); |
855 | } |
856 | } |
857 | |
858 | static void |
859 | test_seq_dcs(uint32_t p, |
860 | bte_seq_arg_t params[16], |
861 | std::u32string const& str, |
862 | int expected_rv = BTE_SEQ_DCS) |
863 | { |
864 | uint32_t i[4]; |
865 | for (uint32_t f = 0x40; f < 0x7f; f++) { |
866 | test_seq_dcs(f, p, params, i, 0, str, expected_rv); |
867 | } |
868 | |
869 | for (uint32_t f = 0x30; f < 0x7f; f++) { |
870 | for (i[0] = 0x20; i[0] < 0x30; i[0]++) { |
871 | test_seq_dcs(f, p, params, i, 1, str, expected_rv); |
872 | for (i[1] = 0x20; i[1] < 0x30; i[1]++) { |
873 | test_seq_dcs(f, p, params, i, 2, str, expected_rv); |
874 | } |
875 | } |
876 | } |
877 | } |
878 | |
879 | static void |
880 | test_seq_dcs(bte_seq_arg_t params[16], |
881 | std::u32string const& str, |
882 | int expected_rv = BTE_SEQ_DCS) |
883 | { |
884 | test_seq_dcs(0, params, str); |
885 | for (uint32_t p = 0x3c; p <= 0x3f; p++) |
886 | test_seq_dcs(p, params, str, expected_rv); |
887 | } |
888 | |
889 | static void |
890 | test_seq_dcs(std::u32string const& str, |
891 | int expected_rv = BTE_SEQ_DCS) |
892 | { |
893 | /* Tests DCS sequences, that is sequences of the form |
894 | * DCS P...P I...I F D...D ST |
895 | * with parameter bytes P from 3/0..3/15, intermediate bytes I from 2/0..2/15 and |
896 | * final byte F from 4/0..7/14. |
897 | * There could be any number of intermediate bytes, but we only test up to 2. |
898 | * There could be any number of extra params bytes, but we only test up to 1. |
899 | * DCS can be either the C1 control itself, or ESC [; ST can be either the C1 |
900 | * control itself, or ESC \\ |
901 | */ |
902 | bte_seq_arg_t params1[16]{ -1, 0, 1, 9, 10, 99, 100, 999, |
903 | 1000, 9999, 10000, 65534, 65535, 65536, -1, -1 }; |
904 | test_seq_dcs(params1, str, expected_rv); |
905 | |
906 | bte_seq_arg_t params2[16]{ 1, -1, -1, -1, 1, -1, 1, 1, |
907 | 1, -1, -1, -1, -1, 1, 1, 1 }; |
908 | test_seq_dcs(params2, str, expected_rv); |
909 | } |
910 | |
911 | static void |
912 | test_seq_dcs_simple(std::u32string const& str, |
913 | int expected_rv = BTE_SEQ_DCS) |
914 | { |
915 | bte_seq_arg_t params[16]{ 1, -1, -1, -1, 1, -1, 1, 1, |
916 | 1, -1, -1, -1, -1, 1, 1, 1 }; |
917 | uint32_t i[4]; |
918 | |
919 | test_seq_dcs(0x40, 0, params, i, 0, str, expected_rv); |
920 | } |
921 | |
922 | static void |
923 | test_seq_dcs(void) |
924 | { |
925 | /* Length exceeded */ |
926 | test_seq_dcs_simple(std::u32string(BTE_SEQ_STRING_MAX_CAPACITY(1 << 12) + 1, 0x100000), BTE_SEQ_NONE); |
927 | |
928 | test_seq_dcs(U""s); |
929 | test_seq_dcs(U"123;TESTING"s); |
930 | } |
931 | |
932 | static void |
933 | test_seq_dcs_known(uint32_t f, |
934 | uint32_t p, |
935 | uint32_t i, |
936 | unsigned int cmd) |
937 | { |
938 | bte_seq_builder b{BTE_SEQ_DCS, f}; |
939 | if (p != 0) |
940 | b.set_param_intro(p); |
941 | if (i != 0) |
942 | b.set_intermediates(&i, 1); |
943 | |
944 | auto rv = feed_parser(b); |
945 | g_assert_cmpint(rv, ==, BTE_SEQ_DCS)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_DCS); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 945, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_DCS", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
946 | g_assert_cmpint(seq.command(), ==, cmd)do { gint64 __n1 = (seq.command()), __n2 = (cmd); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 946, ((const char*) (__PRETTY_FUNCTION__)), "seq.command()" " " "==" " " "cmd", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
947 | } |
948 | |
949 | static void |
950 | test_seq_dcs_known(void) |
951 | { |
952 | parser.reset(); |
953 | |
954 | #define _BTE_SEQ(cmd,type,f,p,ni,i) \ |
955 | test_seq_dcs_known(f, BTE_SEQ_PARAMETER_CHAR_##p, BTE_SEQ_INTERMEDIATE_CHAR_##i, BTE_CMD_##cmd); |
956 | #include "parser-dcs.hh" |
957 | #undef _BTE_SEQ |
958 | } |
959 | |
960 | static void |
961 | test_seq_parse(char const* str) |
962 | { |
963 | std::u32string s; |
964 | s.push_back(0x9B); /* CSI */ |
965 | for (unsigned int i = 0; str[i]; i++) |
966 | s.push_back(str[i]); |
967 | s.push_back(0x6d); /* m = SGR */ |
968 | |
969 | parser.reset(); |
970 | auto rv = feed_parser(s); |
971 | g_assert_cmpint(rv, ==, BTE_SEQ_CSI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_CSI); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 971, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_CSI", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
972 | } |
973 | |
974 | static void |
975 | test_seq_csi_param(char const* str, |
976 | std::vector<int> args, |
977 | std::vector<bool> args_nonfinal) |
978 | { |
979 | g_assert_cmpuint(args.size(), ==, args_nonfinal.size())do { guint64 __n1 = (args.size()), __n2 = (args_nonfinal.size ()); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 979, ((const char*) (__PRETTY_FUNCTION__ )), "args.size()" " " "==" " " "args_nonfinal.size()", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
980 | |
981 | test_seq_parse(str); |
982 | |
983 | if (seq.size() < BTE_PARSER_ARG_MAX(32)) |
984 | g_assert_cmpuint(seq.size(), ==, args.size())do { guint64 __n1 = (seq.size()), __n2 = (args.size()); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 984, ((const char*) (__PRETTY_FUNCTION__)), "seq.size()" " " "==" " " "args.size()", (long double) __n1, "==", (long double ) __n2, 'i'); } while (0); |
985 | |
986 | unsigned int n_final_args = 0; |
987 | for (unsigned int i = 0; i < seq.size(); i++) { |
988 | g_assert_cmpint(seq.param(i), ==, args[i])do { gint64 __n1 = (seq.param(i)), __n2 = (args[i]); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 988, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(i)" " " "==" " " "args[i]", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
989 | |
990 | auto is_nonfinal = args_nonfinal[i]; |
991 | if (!is_nonfinal) |
992 | n_final_args++; |
993 | |
994 | g_assert_cmpint(seq.param_nonfinal(i), ==, is_nonfinal)do { gint64 __n1 = (seq.param_nonfinal(i)), __n2 = (is_nonfinal ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 994, ((const char*) (__PRETTY_FUNCTION__ )), "seq.param_nonfinal(i)" " " "==" " " "is_nonfinal", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
995 | } |
996 | |
997 | g_assert_cmpuint(seq.size_final(), ==, n_final_args)do { guint64 __n1 = (seq.size_final()), __n2 = (n_final_args) ; if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 997, ((const char*) (__PRETTY_FUNCTION__ )), "seq.size_final()" " " "==" " " "n_final_args", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
998 | } |
999 | |
1000 | static void |
1001 | test_seq_csi_param(void) |
1002 | { |
1003 | /* Tests that CSI parameters and subparameters are parsed correctly. */ |
1004 | |
1005 | test_seq_csi_param("", { }, { }); |
1006 | test_seq_csi_param(";", { -1, -1 }, { false, false }); |
1007 | test_seq_csi_param(":", { -1, -1 }, { true, false }); |
1008 | test_seq_csi_param(";:", { -1, -1, -1 }, { false, true, false }); |
1009 | test_seq_csi_param("::;;", { -1, -1, -1, -1, -1 }, { true, true, false, false, false }); |
1010 | |
1011 | test_seq_csi_param("1;2:3:4:5:6;7:8;9:0", |
1012 | { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }, |
1013 | { false, true, true, true, true, false, true, false, true, false }); |
1014 | |
1015 | test_seq_csi_param("1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1", |
1016 | { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
1017 | { false, false, false, false, false, false, false, false, |
1018 | false, false, false, false, false, false, false, false }); |
1019 | |
1020 | test_seq_csi_param("1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", |
1021 | { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
1022 | { true, true, true, true, true, true, true, true, |
1023 | true, true, true, true, true, true, true, false }); |
1024 | |
1025 | } |
1026 | |
1027 | static void |
1028 | test_seq_csi_clear(void) |
1029 | { |
1030 | /* Check that parameters are cleared from when a sequence was aborted. */ |
1031 | |
1032 | bte_seq_builder b0{BTE_SEQ_CSI, 'm'}; |
1033 | b0.set_param_intro(BTE_SEQ_PARAMETER_CHAR_WHAT); |
1034 | for (unsigned int i = 0; i < BTE_PARSER_ARG_MAX(32); ++i) |
1035 | b0.append_param(127 * i + 17); |
1036 | |
1037 | std::u32string str0; |
1038 | b0.to_string(str0); |
1039 | |
1040 | parser.reset(); |
1041 | for (size_t len0 = 1; len0 <= str0.size(); ++len0) { |
1042 | for (unsigned int n_args = 0; n_args < BTE_PARSER_ARG_MAX(32); ++n_args) { |
1043 | feed_parser(str0.substr(0, len0)); |
1044 | |
1045 | bte_seq_builder b1{BTE_SEQ_CSI, 'n'}; |
1046 | b1.set_param_intro(BTE_SEQ_PARAMETER_CHAR_GT); |
1047 | for (unsigned int i = 0; i < n_args; ++i) |
1048 | b1.append_param(257 * i + 31); |
1049 | |
1050 | std::u32string str1; |
1051 | b1.to_string(str1); |
1052 | |
1053 | auto rv = feed_parser(str1); |
1054 | g_assert_cmpint(rv, ==, BTE_SEQ_CSI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_CSI); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1054, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_CSI", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1055 | b1.assert_equal_full(seq); |
1056 | for (unsigned int n = seq.size(); n < BTE_PARSER_ARG_MAX(32); n++) |
1057 | g_assert_true(seq.param_default(n))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_175 ; if (seq.param_default(n)) _g_boolean_var_175 = 1; else _g_boolean_var_175 = 0; _g_boolean_var_175; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1057, ((const char*) ( __PRETTY_FUNCTION__)), "'" "seq.param_default(n)" "' should be TRUE" ); } while (0); |
1058 | } |
1059 | } |
1060 | } |
1061 | |
1062 | static void |
1063 | test_seq_csi_max(std::u32string const& start, |
1064 | std::u32string const& more, |
1065 | int expected_rv = BTE_SEQ_NONE) |
1066 | { |
1067 | parser.reset(); |
1068 | feed_parser(start); |
1069 | feed_parser(more); |
1070 | auto rv = feed_parser(U"m"s); /* final character */ |
1071 | g_assert_cmpint(rv, ==, expected_rv)do { gint64 __n1 = (rv), __n2 = (expected_rv); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1071, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "expected_rv", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1072 | } |
1073 | |
1074 | static void |
1075 | test_seq_csi_max(void) |
1076 | { |
1077 | /* Check that an excessive number of parameters causes the |
1078 | * sequence to be ignored. |
1079 | * |
1080 | * Since SequenceBuilder is limited in the same number of |
1081 | * parameters as the parser, can't use it directly to |
1082 | * produce a sequence with too may parameters. |
1083 | */ |
1084 | |
1085 | bte_seq_builder b{BTE_SEQ_CSI, 'm'}; |
1086 | b.set_param_intro(BTE_SEQ_PARAMETER_CHAR_WHAT); |
1087 | for (unsigned int i = 0; i < BTE_PARSER_ARG_MAX(32); ++i) |
1088 | b.append_param(i); |
1089 | |
1090 | std::u32string str; |
1091 | b.to_string(str); |
1092 | |
1093 | /* The sequence with BTE_PARSER_ARG_MAX args must be parsed */ |
1094 | auto rv = feed_parser(str); |
1095 | g_assert_cmpint(rv, ==, BTE_SEQ_CSI)do { gint64 __n1 = (rv), __n2 = (BTE_SEQ_CSI); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1095, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "BTE_SEQ_CSI", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1096 | |
1097 | /* Now test that adding one more parameter (whether with an |
1098 | * explicit value, or default, causes the sequence to be ignored. |
1099 | */ |
1100 | str.pop_back(); /* erase final character */ |
1101 | test_seq_csi_max(str, U":"s); |
1102 | test_seq_csi_max(str, U";"s); |
1103 | test_seq_csi_max(str, U":12345"s); |
1104 | test_seq_csi_max(str, U";12345"s); |
1105 | test_seq_csi_max(str, U":12345;"s); |
1106 | test_seq_csi_max(str, U";12345:"s); |
1107 | test_seq_csi_max(str, U":12345;"s); |
1108 | test_seq_csi_max(str, U":12345:"s); |
1109 | } |
1110 | |
1111 | static void |
1112 | test_seq_glue_arg(char const* str, |
1113 | unsigned int n_args, |
1114 | unsigned int n_final_args) |
1115 | { |
1116 | test_seq_parse(str); |
1117 | |
1118 | auto raw_seq = *seq.seq_ptr(); |
1119 | g_assert_cmpuint(seq.size(), ==, n_args)do { guint64 __n1 = (seq.size()), __n2 = (n_args); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1119, ((const char*) (__PRETTY_FUNCTION__)), "seq.size()" " " "==" " " "n_args", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1120 | g_assert_cmpuint(raw_seq->n_args, ==, n_args)do { guint64 __n1 = (raw_seq->n_args), __n2 = (n_args); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0 ), "../src/parser-test.cc", 1120, ((const char*) (__PRETTY_FUNCTION__ )), "raw_seq->n_args" " " "==" " " "n_args", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1121 | g_assert_cmpuint(seq.size_final(), ==, n_final_args)do { guint64 __n1 = (seq.size_final()), __n2 = (n_final_args) ; if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1121, ((const char*) (__PRETTY_FUNCTION__ )), "seq.size_final()" " " "==" " " "n_final_args", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
1122 | g_assert_cmpuint(raw_seq->n_final_args, ==, n_final_args)do { guint64 __n1 = (raw_seq->n_final_args), __n2 = (n_final_args ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1122, ((const char*) (__PRETTY_FUNCTION__ )), "raw_seq->n_final_args" " " "==" " " "n_final_args", ( long double) __n1, "==", (long double) __n2, 'i'); } while (0 ); |
1123 | |
1124 | g_assert_cmpuint(seq.type(), ==, raw_seq->type)do { guint64 __n1 = (seq.type()), __n2 = (raw_seq->type); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0 ), "../src/parser-test.cc", 1124, ((const char*) (__PRETTY_FUNCTION__ )), "seq.type()" " " "==" " " "raw_seq->type", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
1125 | g_assert_cmpuint(seq.command(), ==, raw_seq->command)do { guint64 __n1 = (seq.command()), __n2 = (raw_seq->command ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1125, ((const char*) (__PRETTY_FUNCTION__ )), "seq.command()" " " "==" " " "raw_seq->command", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1126 | g_assert_cmpuint(seq.terminator(), ==, raw_seq->terminator)do { guint64 __n1 = (seq.terminator()), __n2 = (raw_seq->terminator ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1126, ((const char*) (__PRETTY_FUNCTION__ )), "seq.terminator()" " " "==" " " "raw_seq->terminator", (long double) __n1, "==", (long double) __n2, 'i'); } while ( 0); |
1127 | |
1128 | for (unsigned int i = 0; i < raw_seq->n_args; i++) |
1129 | g_assert_cmpuint(seq.param(i), ==, bte_seq_arg_value(raw_seq->args[i]))do { guint64 __n1 = (seq.param(i)), __n2 = (bte_seq_arg_value (raw_seq->args[i])); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc", 1129, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(i)" " " "==" " " "bte_seq_arg_value(raw_seq->args[i])" , (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1130 | } |
1131 | |
1132 | static void |
1133 | test_seq_glue_arg(void) |
1134 | { |
1135 | test_seq_glue_arg(":0:1000;2;3;4;:;", 9, 6); |
1136 | g_assert_cmpuint(seq.cbegin(), ==, 0)do { guint64 __n1 = (seq.cbegin()), __n2 = (0); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1136, ((const char*) (__PRETTY_FUNCTION__)), "seq.cbegin()" " " "==" " " "0", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1137 | g_assert_cmpuint(seq.cend(), ==, 9)do { guint64 __n1 = (seq.cend()), __n2 = (9); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1137, ((const char*) (__PRETTY_FUNCTION__)), "seq.cend()" " " "==" " " "9", (long double) __n1, "==", (long double) __n2, 'i' ); } while (0); |
1138 | |
1139 | auto it = seq.cbegin(); |
1140 | g_assert_cmpuint(it, ==, 0)do { guint64 __n1 = (it), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1140, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "0", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1141 | it = seq.next(it); |
1142 | g_assert_cmpuint(it, ==, 3)do { guint64 __n1 = (it), __n2 = (3); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1142, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "3", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1143 | it = seq.next(it); |
1144 | g_assert_cmpuint(it, ==, 4)do { guint64 __n1 = (it), __n2 = (4); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1144, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "4", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1145 | it = seq.next(it); |
1146 | g_assert_cmpuint(it, ==, 5)do { guint64 __n1 = (it), __n2 = (5); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1146, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "5", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1147 | it = seq.next(it); |
1148 | g_assert_cmpuint(it, ==, 6)do { guint64 __n1 = (it), __n2 = (6); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1148, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "6", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1149 | it = seq.next(it); |
1150 | g_assert_cmpuint(it, ==, 8)do { guint64 __n1 = (it), __n2 = (8); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1150, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "8", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1151 | it = seq.next(it); |
1152 | g_assert_cmpuint(it, ==, 9)do { guint64 __n1 = (it), __n2 = (9); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1152, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "9", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1153 | |
1154 | it = seq.cbegin(); |
1155 | g_assert_cmpint(seq.param(it++), ==, -1)do { gint64 __n1 = (seq.param(it++)), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1155, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1156 | g_assert_cmpint(seq.param(it++), ==, 0)do { gint64 __n1 = (seq.param(it++)), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1156, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "0", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1157 | g_assert_cmpint(seq.param(it++), ==, 1000)do { gint64 __n1 = (seq.param(it++)), __n2 = (1000); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1157, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "1000", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1158 | g_assert_cmpint(seq.param(it++), ==, 2)do { gint64 __n1 = (seq.param(it++)), __n2 = (2); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1158, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "2", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1159 | g_assert_cmpint(seq.param(it++), ==, 3)do { gint64 __n1 = (seq.param(it++)), __n2 = (3); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1159, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "3", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1160 | g_assert_cmpint(seq.param(it++), ==, 4)do { gint64 __n1 = (seq.param(it++)), __n2 = (4); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1160, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "4", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1161 | g_assert_cmpint(seq.param(it++), ==, -1)do { gint64 __n1 = (seq.param(it++)), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1161, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1162 | g_assert_cmpint(seq.param(it++), ==, -1)do { gint64 __n1 = (seq.param(it++)), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1162, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1163 | g_assert_cmpint(seq.param(it++), ==, -1)do { gint64 __n1 = (seq.param(it++)), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1163, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it++)" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1164 | g_assert_cmpint(it, ==, seq.cend())do { gint64 __n1 = (it), __n2 = (seq.cend()); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1164, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "seq.cend()", (long double) __n1, "==", (long double) __n2, 'i' ); } while (0); |
1165 | |
1166 | it = seq.cbegin(); |
1167 | g_assert_cmpint(seq.param(it, -2), ==, -2)do { gint64 __n1 = (seq.param(it, -2)), __n2 = (-2); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1167, ((const char*) (__PRETTY_FUNCTION__)), "seq.param(it, -2)" " " "==" " " "-2", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1168 | g_assert_cmpint(seq.param(it, -2, 0, 100), ==, 0)do { gint64 __n1 = (seq.param(it, -2, 0, 100)), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0 ), "../src/parser-test.cc", 1168, ((const char*) (__PRETTY_FUNCTION__ )), "seq.param(it, -2, 0, 100)" " " "==" " " "0", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
1169 | it++; it++; |
1170 | g_assert_cmpint(seq.param(it, -2), ==, seq.param(it))do { gint64 __n1 = (seq.param(it, -2)), __n2 = (seq.param(it) ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1170, ((const char*) (__PRETTY_FUNCTION__ )), "seq.param(it, -2)" " " "==" " " "seq.param(it)", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
1171 | g_assert_cmpint(seq.param(it, -2, 20, 100), ==, 100)do { gint64 __n1 = (seq.param(it, -2, 20, 100)), __n2 = (100) ; if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1171, ((const char*) (__PRETTY_FUNCTION__ )), "seq.param(it, -2, 20, 100)" " " "==" " " "100", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
1172 | g_assert_cmpint(seq.param(it, -2, 200, 2000), ==, 1000)do { gint64 __n1 = (seq.param(it, -2, 200, 2000)), __n2 = (1000 ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1172, ((const char*) (__PRETTY_FUNCTION__ )), "seq.param(it, -2, 200, 2000)" " " "==" " " "1000", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1173 | g_assert_cmpint(seq.param(it, -2, 2000, 4000), ==, 2000)do { gint64 __n1 = (seq.param(it, -2, 2000, 4000)), __n2 = (2000 ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1173, ((const char*) (__PRETTY_FUNCTION__ )), "seq.param(it, -2, 2000, 4000)" " " "==" " " "2000", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1174 | |
1175 | int a, b, c,d ; |
1176 | it = seq.cbegin(); |
1177 | g_assert_false(seq.collect(it, {&a, &b, &c}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_176 ; if (!(seq.collect(it, {&a, &b, &c}))) _g_boolean_var_176 = 1; else _g_boolean_var_176 = 0; _g_boolean_var_176; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1177, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a, &b, &c})" "' should be FALSE"); } while (0); |
1178 | g_assert_true(seq.collect_subparams(it, {&a}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_177 ; if (seq.collect_subparams(it, {&a})) _g_boolean_var_177 = 1; else _g_boolean_var_177 = 0; _g_boolean_var_177; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1178, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect_subparams(it, {&a})" "' should be TRUE"); } while (0); |
1179 | g_assert_true(seq.collect_subparams(it, {&a, &b}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_178 ; if (seq.collect_subparams(it, {&a, &b})) _g_boolean_var_178 = 1; else _g_boolean_var_178 = 0; _g_boolean_var_178; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1179, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect_subparams(it, {&a, &b})" "' should be TRUE"); } while (0); |
1180 | g_assert_true(seq.collect_subparams(it, {&a, &b, &c}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_179 ; if (seq.collect_subparams(it, {&a, &b, &c})) _g_boolean_var_179 = 1; else _g_boolean_var_179 = 0; _g_boolean_var_179; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1180, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect_subparams(it, {&a, &b, &c})" "' should be TRUE"); } while (0); |
1181 | g_assert_cmpint(a, ==, -1)do { gint64 __n1 = (a), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1181, ((const char*) (__PRETTY_FUNCTION__)), "a" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1182 | g_assert_cmpint(b, ==, 0)do { gint64 __n1 = (b), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc", 1182, ((const char*) (__PRETTY_FUNCTION__)), "b" " " "==" " " "0", (long double) __n1 , "==", (long double) __n2, 'i'); } while (0); |
1183 | g_assert_cmpint(c, ==, 1000)do { gint64 __n1 = (c), __n2 = (1000); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1183, ((const char*) (__PRETTY_FUNCTION__)), "c" " " "==" " " "1000", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1184 | g_assert_false(seq.collect_subparams(it, {&a, &b, &c, &d}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_180 ; if (!(seq.collect_subparams(it, {&a, &b, &c, & d}))) _g_boolean_var_180 = 1; else _g_boolean_var_180 = 0; _g_boolean_var_180 ; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1184, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect_subparams(it, {&a, &b, &c, &d})" "' should be FALSE"); } while (0); |
1185 | |
1186 | it = seq.next(it); |
1187 | g_assert_true(seq.collect(it, {&a}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_181 ; if (seq.collect(it, {&a})) _g_boolean_var_181 = 1; else _g_boolean_var_181 = 0; _g_boolean_var_181; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 1187, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a})" "' should be TRUE" ); } while (0); |
1188 | g_assert_true(seq.collect(it, {&a, &b}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_182 ; if (seq.collect(it, {&a, &b})) _g_boolean_var_182 = 1; else _g_boolean_var_182 = 0; _g_boolean_var_182; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1188, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a, &b})" "' should be TRUE"); } while (0); |
1189 | g_assert_true(seq.collect(it, {&a, &b, &c}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_183 ; if (seq.collect(it, {&a, &b, &c})) _g_boolean_var_183 = 1; else _g_boolean_var_183 = 0; _g_boolean_var_183; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1189, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a, &b, &c})" "' should be TRUE"); } while (0); |
1190 | g_assert_cmpint(a, ==, 2)do { gint64 __n1 = (a), __n2 = (2); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc", 1190, ((const char*) (__PRETTY_FUNCTION__)), "a" " " "==" " " "2", (long double) __n1 , "==", (long double) __n2, 'i'); } while (0); |
1191 | g_assert_cmpint(b, ==, 3)do { gint64 __n1 = (b), __n2 = (3); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc", 1191, ((const char*) (__PRETTY_FUNCTION__)), "b" " " "==" " " "3", (long double) __n1 , "==", (long double) __n2, 'i'); } while (0); |
1192 | g_assert_cmpint(c, ==, 4)do { gint64 __n1 = (c), __n2 = (4); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc", 1192, ((const char*) (__PRETTY_FUNCTION__)), "c" " " "==" " " "4", (long double) __n1 , "==", (long double) __n2, 'i'); } while (0); |
1193 | g_assert_false(seq.collect(it, {&a, &b, &c, &d}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_184 ; if (!(seq.collect(it, {&a, &b, &c, &d}))) _g_boolean_var_184 = 1; else _g_boolean_var_184 = 0; _g_boolean_var_184; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1193, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a, &b, &c, &d})" "' should be FALSE"); } while (0); |
1194 | |
1195 | it = seq.next(it); |
1196 | it = seq.next(it); |
1197 | it = seq.next(it); |
1198 | g_assert_false(seq.collect(it, {&a}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_185 ; if (!(seq.collect(it, {&a}))) _g_boolean_var_185 = 1; else _g_boolean_var_185 = 0; _g_boolean_var_185; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 1198, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a})" "' should be FALSE" ); } while (0); |
1199 | g_assert_true(seq.collect_subparams(it, {&a}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_186 ; if (seq.collect_subparams(it, {&a})) _g_boolean_var_186 = 1; else _g_boolean_var_186 = 0; _g_boolean_var_186; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1199, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect_subparams(it, {&a})" "' should be TRUE"); } while (0); |
1200 | g_assert_true(seq.collect_subparams(it, {&a, &b}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_187 ; if (seq.collect_subparams(it, {&a, &b})) _g_boolean_var_187 = 1; else _g_boolean_var_187 = 0; _g_boolean_var_187; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1200, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect_subparams(it, {&a, &b})" "' should be TRUE"); } while (0); |
1201 | g_assert_cmpint(a, ==, -1)do { gint64 __n1 = (a), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1201, ((const char*) (__PRETTY_FUNCTION__)), "a" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1202 | g_assert_cmpint(b, ==, -1)do { gint64 __n1 = (b), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1202, ((const char*) (__PRETTY_FUNCTION__)), "b" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1203 | g_assert_false(seq.collect_subparams(it, {&a, &b, &c}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_188 ; if (!(seq.collect_subparams(it, {&a, &b, &c}))) _g_boolean_var_188 = 1; else _g_boolean_var_188 = 0; _g_boolean_var_188 ; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1203, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect_subparams(it, {&a, &b, &c})" "' should be FALSE"); } while (0); |
1204 | it = seq.next(it); |
1205 | g_assert_true(seq.collect(it, {&a}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_189 ; if (seq.collect(it, {&a})) _g_boolean_var_189 = 1; else _g_boolean_var_189 = 0; _g_boolean_var_189; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 1205, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a})" "' should be TRUE" ); } while (0); |
1206 | g_assert_cmpint(a, ==, -1)do { gint64 __n1 = (a), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1206, ((const char*) (__PRETTY_FUNCTION__)), "a" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1207 | g_assert_true(seq.collect(it, {&a, &b}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_190 ; if (seq.collect(it, {&a, &b})) _g_boolean_var_190 = 1; else _g_boolean_var_190 = 0; _g_boolean_var_190; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1207, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a, &b})" "' should be TRUE"); } while (0); /* past-the-end params are final and default */ |
1208 | g_assert_cmpint(a, ==, -1)do { gint64 __n1 = (a), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1208, ((const char*) (__PRETTY_FUNCTION__)), "a" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1209 | g_assert_cmpint(b, ==, -1)do { gint64 __n1 = (b), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1209, ((const char*) (__PRETTY_FUNCTION__)), "b" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1210 | g_assert_true(seq.collect(it, {&a, &b, &c}))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_191 ; if (seq.collect(it, {&a, &b, &c})) _g_boolean_var_191 = 1; else _g_boolean_var_191 = 0; _g_boolean_var_191; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1210, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.collect(it, {&a, &b, &c})" "' should be TRUE"); } while (0); /* past-the-end params are final and default */ |
1211 | g_assert_cmpint(a, ==, -1)do { gint64 __n1 = (a), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1211, ((const char*) (__PRETTY_FUNCTION__)), "a" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1212 | g_assert_cmpint(b, ==, -1)do { gint64 __n1 = (b), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1212, ((const char*) (__PRETTY_FUNCTION__)), "b" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1213 | g_assert_cmpint(c, ==, -1)do { gint64 __n1 = (c), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1213, ((const char*) (__PRETTY_FUNCTION__)), "c" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1214 | |
1215 | it = seq.cbegin(); |
1216 | g_assert_cmpint(seq.collect1(it, -2), ==, -2)do { gint64 __n1 = (seq.collect1(it, -2)), __n2 = (-2); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1216, ((const char*) (__PRETTY_FUNCTION__)), "seq.collect1(it, -2)" " " "==" " " "-2", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1217 | it = seq.next(it); |
1218 | g_assert_cmpint(seq.collect1(it), ==, 2)do { gint64 __n1 = (seq.collect1(it)), __n2 = (2); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1218, ((const char*) (__PRETTY_FUNCTION__)), "seq.collect1(it)" " " "==" " " "2", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1219 | g_assert_cmpint(seq.collect1(it), ==, 2)do { gint64 __n1 = (seq.collect1(it)), __n2 = (2); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1219, ((const char*) (__PRETTY_FUNCTION__)), "seq.collect1(it)" " " "==" " " "2", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1220 | it = seq.next(it); |
1221 | g_assert_cmpint(seq.collect1(it), ==, 3)do { gint64 __n1 = (seq.collect1(it)), __n2 = (3); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1221, ((const char*) (__PRETTY_FUNCTION__)), "seq.collect1(it)" " " "==" " " "3", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1222 | it = seq.next(it); |
1223 | g_assert_cmpint(seq.collect1(it), ==, 4)do { gint64 __n1 = (seq.collect1(it)), __n2 = (4); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1223, ((const char*) (__PRETTY_FUNCTION__)), "seq.collect1(it)" " " "==" " " "4", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1224 | it = seq.next(it); |
1225 | g_assert_cmpint(seq.collect1(it, -3), ==, -3)do { gint64 __n1 = (seq.collect1(it, -3)), __n2 = (-3); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1225, ((const char*) (__PRETTY_FUNCTION__)), "seq.collect1(it, -3)" " " "==" " " "-3", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1226 | it = seq.next(it); |
1227 | g_assert_cmpint(seq.collect1(it), ==, -1)do { gint64 __n1 = (seq.collect1(it)), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1227, ((const char*) (__PRETTY_FUNCTION__)), "seq.collect1(it)" " " "==" " " "-1", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1228 | g_assert_cmpint(seq.collect1(it, 42), ==, 42)do { gint64 __n1 = (seq.collect1(it, 42)), __n2 = (42); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1228, ((const char*) (__PRETTY_FUNCTION__)), "seq.collect1(it, 42)" " " "==" " " "42", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1229 | g_assert_cmpint(seq.collect1(it, -1, 0, 100), ==, 0)do { gint64 __n1 = (seq.collect1(it, -1, 0, 100)), __n2 = (0) ; if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1229, ((const char*) (__PRETTY_FUNCTION__ )), "seq.collect1(it, -1, 0, 100)" " " "==" " " "0", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
1230 | g_assert_cmpint(seq.collect1(it, 42, 0, 100), ==, 42)do { gint64 __n1 = (seq.collect1(it, 42, 0, 100)), __n2 = (42 ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1230, ((const char*) (__PRETTY_FUNCTION__ )), "seq.collect1(it, 42, 0, 100)" " " "==" " " "42", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
1231 | g_assert_cmpint(seq.collect1(it, 42, 0, 10), ==, 10)do { gint64 __n1 = (seq.collect1(it, 42, 0, 10)), __n2 = (10) ; if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1231, ((const char*) (__PRETTY_FUNCTION__ )), "seq.collect1(it, 42, 0, 10)" " " "==" " " "10", (long double ) __n1, "==", (long double) __n2, 'i'); } while (0); |
1232 | g_assert_cmpint(seq.collect1(it, 42, 100, 200), ==, 100)do { gint64 __n1 = (seq.collect1(it, 42, 100, 200)), __n2 = ( 100); if (__n1 == __n2) ; else g_assertion_message_cmpnum ((( gchar*) 0), "../src/parser-test.cc", 1232, ((const char*) (__PRETTY_FUNCTION__ )), "seq.collect1(it, 42, 100, 200)" " " "==" " " "100", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1233 | } |
1234 | |
1235 | static int |
1236 | feed_parser_st(bte_seq_builder& b, |
1237 | bool c1 = false, |
1238 | ssize_t max_arg_str_len = -1, |
1239 | u32SequenceBuilder::Introducer introducer = u32SequenceBuilder::Introducer::DEFAULT, |
1240 | u32SequenceBuilder::ST st = u32SequenceBuilder::ST::DEFAULT) |
1241 | { |
1242 | std::u32string s; |
1243 | b.to_string(s, c1, max_arg_str_len, introducer, st); |
1244 | |
1245 | auto rv = feed_parser(s); |
1246 | if (rv != BTE_SEQ_OSC) |
1247 | return rv; |
1248 | |
1249 | switch (st) { |
1250 | case u32SequenceBuilder::ST::NONE: |
1251 | g_assert_cmpuint(seq.terminator(), ==, 0)do { guint64 __n1 = (seq.terminator()), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1251, ((const char*) (__PRETTY_FUNCTION__)), "seq.terminator()" " " "==" " " "0", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1252 | break; |
1253 | case u32SequenceBuilder::ST::DEFAULT: |
1254 | g_assert_cmpuint(seq.terminator(), ==, c1 ? 0x9c /* ST */ : 0x5c /* BACKSLASH */)do { guint64 __n1 = (seq.terminator()), __n2 = (c1 ? 0x9c : 0x5c ); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar *) 0), "../src/parser-test.cc", 1254, ((const char*) (__PRETTY_FUNCTION__ )), "seq.terminator()" " " "==" " " "c1 ? 0x9c : 0x5c", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1255 | break; |
1256 | case u32SequenceBuilder::ST::C0: |
1257 | g_assert_cmpuint(seq.terminator(), ==, 0x5c /* BACKSLASH */)do { guint64 __n1 = (seq.terminator()), __n2 = (0x5c); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1257, ((const char*) (__PRETTY_FUNCTION__)), "seq.terminator()" " " "==" " " "0x5c", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1258 | break; |
1259 | case u32SequenceBuilder::ST::C1: |
1260 | g_assert_cmpuint(seq.terminator(), ==, 0x9c /* ST */)do { guint64 __n1 = (seq.terminator()), __n2 = (0x9c); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1260, ((const char*) (__PRETTY_FUNCTION__)), "seq.terminator()" " " "==" " " "0x9c", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1261 | break; |
1262 | case u32SequenceBuilder::ST::BEL: |
1263 | g_assert_cmpuint(seq.terminator(), ==, 0x7 /* BEL */)do { guint64 __n1 = (seq.terminator()), __n2 = (0x7); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1263, ((const char*) (__PRETTY_FUNCTION__)), "seq.terminator()" " " "==" " " "0x7", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1264 | break; |
1265 | } |
1266 | |
1267 | return rv; |
1268 | } |
1269 | |
1270 | static void |
1271 | test_seq_osc(std::u32string const& str, |
1272 | int expected_rv = BTE_SEQ_OSC, |
1273 | bool c1 = true, |
1274 | ssize_t max_arg_str_len = -1, |
1275 | u32SequenceBuilder::Introducer introducer = u32SequenceBuilder::Introducer::DEFAULT, |
1276 | u32SequenceBuilder::ST st = u32SequenceBuilder::ST::DEFAULT) |
1277 | { |
1278 | bte_seq_builder b{BTE_SEQ_OSC, str}; |
1279 | |
1280 | parser.reset(); |
1281 | auto rv = feed_parser_st(b, c1, max_arg_str_len, introducer, st); |
1282 | g_assert_cmpint(rv, ==, expected_rv)do { gint64 __n1 = (rv), __n2 = (expected_rv); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1282, ((const char*) (__PRETTY_FUNCTION__)), "rv" " " "==" " " "expected_rv", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1283 | #if 0 |
1284 | if (rv != BTE_SEQ_NONE) |
1285 | b.assert_equal(seq); |
1286 | #endif |
1287 | |
1288 | if (expected_rv != BTE_SEQ_OSC) |
1289 | return; |
1290 | |
1291 | if (max_arg_str_len < 0 || size_t(max_arg_str_len) == str.size()) |
1292 | g_assert_true(seq.string() == str)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_192 ; if (seq.string() == str) _g_boolean_var_192 = 1; else _g_boolean_var_192 = 0; _g_boolean_var_192; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1292, ((const char*) ( __PRETTY_FUNCTION__)), "'" "seq.string() == str" "' should be TRUE" ); } while (0); |
1293 | else |
1294 | g_assert_true(seq.string() == str.substr(0, max_arg_str_len))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_193 ; if (seq.string() == str.substr(0, max_arg_str_len)) _g_boolean_var_193 = 1; else _g_boolean_var_193 = 0; _g_boolean_var_193; }), 1) ) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1294, ((const char*) (__PRETTY_FUNCTION__)), "'" "seq.string() == str.substr(0, max_arg_str_len)" "' should be TRUE"); } while (0); |
1295 | } |
1296 | |
1297 | static int |
1298 | controls_match(bool c1, |
1299 | u32SequenceBuilder::Introducer introducer, |
1300 | u32SequenceBuilder::ST st, |
1301 | bool allow_bel, |
1302 | int expected_rv) |
1303 | { |
1304 | if (introducer == u32SequenceBuilder::Introducer::DEFAULT) |
1305 | introducer = c1 ? u32SequenceBuilder::Introducer::C1 : u32SequenceBuilder::Introducer::C0; |
1306 | if (st == u32SequenceBuilder::ST::DEFAULT) |
1307 | st = c1 ? u32SequenceBuilder::ST::C1 : u32SequenceBuilder::ST::C0; |
1308 | if ((introducer == u32SequenceBuilder::Introducer::C0 && |
1309 | (st == u32SequenceBuilder::ST::C0 || (allow_bel && st == u32SequenceBuilder::ST::BEL))) || |
1310 | (introducer == u32SequenceBuilder::Introducer::C1 && |
1311 | st == u32SequenceBuilder::ST::C1)) |
1312 | return expected_rv; |
1313 | return BTE_SEQ_IGNORE; |
1314 | } |
1315 | |
1316 | static void |
1317 | test_seq_osc(void) |
1318 | { |
1319 | /* Simple */ |
1320 | test_seq_osc(U""s); |
1321 | test_seq_osc(U"TEST"s); |
1322 | |
1323 | /* String of any supported length */ |
1324 | for (unsigned int len = 0; len < BTE_SEQ_STRING_MAX_CAPACITY(1 << 12); ++len) |
1325 | test_seq_osc(std::u32string(len, 0x10000+len)); |
1326 | |
1327 | /* Length exceeded */ |
1328 | test_seq_osc(std::u32string(BTE_SEQ_STRING_MAX_CAPACITY(1 << 12) + 1, 0x100000), BTE_SEQ_IGNORE); |
1329 | |
1330 | /* Test all introducer/ST combinations */ |
1331 | for (auto introducer : { u32SequenceBuilder::Introducer::DEFAULT, |
1332 | u32SequenceBuilder::Introducer::C0, |
1333 | u32SequenceBuilder::Introducer::C1 }) { |
1334 | for (auto st : {u32SequenceBuilder::ST::DEFAULT, |
1335 | u32SequenceBuilder::ST::C0, |
1336 | u32SequenceBuilder::ST::C1, |
1337 | u32SequenceBuilder::ST::BEL }) { |
1338 | for (auto c1 : { false, true }) { |
1339 | int expected_rv = controls_match(c1, introducer, st, true, BTE_SEQ_OSC); |
1340 | test_seq_osc(U"TEST"s, expected_rv, c1, -1, introducer, st); |
1341 | } |
1342 | } |
1343 | } |
1344 | } |
1345 | |
1346 | static void |
1347 | test_seq_glue_string(void) |
1348 | { |
1349 | std::u32string str{U"TEST"s}; |
1350 | test_seq_osc(str); |
1351 | |
1352 | g_assert_true(seq.string() == str)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_194 ; if (seq.string() == str) _g_boolean_var_194 = 1; else _g_boolean_var_194 = 0; _g_boolean_var_194; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1352, ((const char*) ( __PRETTY_FUNCTION__)), "'" "seq.string() == str" "' should be TRUE" ); } while (0); |
1353 | } |
1354 | |
1355 | static void |
1356 | test_seq_glue_string_tokeniser(void) |
1357 | { |
1358 | std::string str{"a;1b:17:test::b:;3;5;def;17 a;ghi;"s}; |
1359 | |
1360 | StringTokeniser tokeniser{str, ';'}; |
1361 | |
1362 | auto start = tokeniser.cbegin(); |
1363 | auto end = tokeniser.cend(); |
1364 | |
1365 | auto pit = start; |
1366 | for (auto it : {"a"s, "1b:17:test::b:"s, "3"s, "5"s, "def"s, "17 a"s, "ghi"s, ""s}) { |
1367 | g_assert_true(it == *pit)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_195 ; if (it == *pit) _g_boolean_var_195 = 1; else _g_boolean_var_195 = 0; _g_boolean_var_195; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1367, ((const char*) ( __PRETTY_FUNCTION__)), "'" "it == *pit" "' should be TRUE"); } while (0); |
1368 | |
1369 | /* Use std::find to see if the InputIterator implementation |
1370 | * is complete and correct. |
1371 | */ |
1372 | auto fit = std::find(start, end, it); |
1373 | g_assert_true(fit == pit)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_196 ; if (fit == pit) _g_boolean_var_196 = 1; else _g_boolean_var_196 = 0; _g_boolean_var_196; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1373, ((const char*) ( __PRETTY_FUNCTION__)), "'" "fit == pit" "' should be TRUE"); } while (0); |
1374 | |
1375 | ++pit; |
1376 | } |
1377 | g_assert_true(pit == end)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_197 ; if (pit == end) _g_boolean_var_197 = 1; else _g_boolean_var_197 = 0; _g_boolean_var_197; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1377, ((const char*) ( __PRETTY_FUNCTION__)), "'" "pit == end" "' should be TRUE"); } while (0); |
1378 | |
1379 | auto len = str.size(); |
1380 | size_t pos = 0; |
1381 | pit = start; |
1382 | for (auto it : {1, 14, 1, 1, 3, 4, 3, 0}) { |
1383 | g_assert_cmpuint(it, ==, pit.size())do { guint64 __n1 = (it), __n2 = (pit.size()); if (__n1 == __n2 ) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1383, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "pit.size()", (long double) __n1, "==", (long double) __n2, 'i' ); } while (0); |
1384 | g_assert_cmpuint(len, ==, pit.size_remaining())do { guint64 __n1 = (len), __n2 = (pit.size_remaining()); if ( __n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0) , "../src/parser-test.cc", 1384, ((const char*) (__PRETTY_FUNCTION__ )), "len" " " "==" " " "pit.size_remaining()", (long double) __n1 , "==", (long double) __n2, 'i'); } while (0); |
1385 | |
1386 | g_assert_true(pit.string_remaining() == str.substr(pos, std::string::npos))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_198 ; if (pit.string_remaining() == str.substr(pos, std::string:: npos)) _g_boolean_var_198 = 1; else _g_boolean_var_198 = 0; _g_boolean_var_198 ; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc" , 1386, ((const char*) (__PRETTY_FUNCTION__)), "'" "pit.string_remaining() == str.substr(pos, std::string::npos)" "' should be TRUE"); } while (0); |
1387 | |
1388 | len -= it + 1; |
1389 | pos += it + 1; |
1390 | |
1391 | ++pit; |
1392 | } |
1393 | g_assert_cmpuint(len + 1, ==, 0)do { guint64 __n1 = (len + 1), __n2 = (0); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1393, ((const char*) (__PRETTY_FUNCTION__)), "len + 1" " " "==" " " "0", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1394 | g_assert_cmpuint(pos, ==, str.size() + 1)do { guint64 __n1 = (pos), __n2 = (str.size() + 1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1394, ((const char*) (__PRETTY_FUNCTION__)), "pos" " " "==" " " "str.size() + 1", (long double) __n1, "==", (long double ) __n2, 'i'); } while (0); |
1395 | |
1396 | pit = start; |
1397 | for (auto it : {-2, -2, 3, 5, -2, -2, -2, -1}) { |
1398 | int num; |
1399 | bool v = pit.number(num); |
1400 | if (it == -2) |
1401 | g_assert_false(v)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_199 ; if (!(v)) _g_boolean_var_199 = 1; else _g_boolean_var_199 = 0; _g_boolean_var_199; }), 1)) ; else g_assertion_message (( (gchar*) 0), "../src/parser-test.cc", 1401, ((const char*) (__PRETTY_FUNCTION__ )), "'" "v" "' should be FALSE"); } while (0); |
1402 | else |
1403 | g_assert_cmpint(it, ==, num)do { gint64 __n1 = (it), __n2 = (num); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc" , 1403, ((const char*) (__PRETTY_FUNCTION__)), "it" " " "==" " " "num", (long double) __n1, "==", (long double) __n2, 'i'); } while (0); |
1404 | |
1405 | ++pit; |
1406 | } |
1407 | |
1408 | /* Test range for */ |
1409 | for (auto it : tokeniser) |
1410 | ; |
1411 | |
1412 | /* Test different separator */ |
1413 | pit = start; |
1414 | ++pit; |
1415 | |
1416 | auto substr = *pit; |
1417 | StringTokeniser subtokeniser{substr, ':'}; |
1418 | |
1419 | auto subpit = subtokeniser.cbegin(); |
1420 | for (auto it : {"1b"s, "17"s, "test"s, ""s, "b"s, ""s}) { |
1421 | g_assert_true(it == *subpit)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_200 ; if (it == *subpit) _g_boolean_var_200 = 1; else _g_boolean_var_200 = 0; _g_boolean_var_200; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1421, ((const char*) ( __PRETTY_FUNCTION__)), "'" "it == *subpit" "' should be TRUE" ); } while (0); |
1422 | |
1423 | ++subpit; |
1424 | } |
1425 | g_assert_true(subpit == subtokeniser.cend())do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_201 ; if (subpit == subtokeniser.cend()) _g_boolean_var_201 = 1; else _g_boolean_var_201 = 0; _g_boolean_var_201; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 1425, ((const char*) (__PRETTY_FUNCTION__)), "'" "subpit == subtokeniser.cend()" "' should be TRUE" ); } while (0); |
1426 | |
1427 | /* Test another string, one that doesn't end with an empty token */ |
1428 | std::string str2{"abc;defghi"s}; |
1429 | StringTokeniser tokeniser2{str2, ';'}; |
1430 | |
1431 | g_assert_cmpint(std::distance(tokeniser2.cbegin(), tokeniser2.cend()), ==, 2)do { gint64 __n1 = (std::distance(tokeniser2.cbegin(), tokeniser2 .cend())), __n2 = (2); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc", 1431, ((const char*) (__PRETTY_FUNCTION__)), "std::distance(tokeniser2.cbegin(), tokeniser2.cend())" " " "==" " " "2", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1432 | auto pit2 = tokeniser2.cbegin(); |
1433 | g_assert_true(*pit2 == "abc"s)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_202 ; if (*pit2 == "abc"s) _g_boolean_var_202 = 1; else _g_boolean_var_202 = 0; _g_boolean_var_202; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1433, ((const char*) ( __PRETTY_FUNCTION__)), "'" "*pit2 == \"abc\"s" "' should be TRUE" ); } while (0); |
1434 | ++pit2; |
1435 | g_assert_true(*pit2 == "defghi"s)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_203 ; if (*pit2 == "defghi"s) _g_boolean_var_203 = 1; else _g_boolean_var_203 = 0; _g_boolean_var_203; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1435, ((const char*) ( __PRETTY_FUNCTION__)), "'" "*pit2 == \"defghi\"s" "' should be TRUE" ); } while (0); |
1436 | ++pit2; |
1437 | g_assert_true(pit2 == tokeniser2.cend())do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_204 ; if (pit2 == tokeniser2.cend()) _g_boolean_var_204 = 1; else _g_boolean_var_204 = 0; _g_boolean_var_204; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 1437, ((const char*) (__PRETTY_FUNCTION__)), "'" "pit2 == tokeniser2.cend()" "' should be TRUE" ); } while (0); |
1438 | |
1439 | /* Test another string, one that starts with an empty token */ |
1440 | std::string str3{";abc"s}; |
1441 | StringTokeniser tokeniser3{str3, ';'}; |
1442 | |
1443 | g_assert_cmpint(std::distance(tokeniser3.cbegin(), tokeniser3.cend()), ==, 2)do { gint64 __n1 = (std::distance(tokeniser3.cbegin(), tokeniser3 .cend())), __n2 = (2); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc", 1443, ((const char*) (__PRETTY_FUNCTION__)), "std::distance(tokeniser3.cbegin(), tokeniser3.cend())" " " "==" " " "2", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1444 | auto pit3 = tokeniser3.cbegin(); |
1445 | g_assert_true(*pit3 == ""s)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_205 ; if (*pit3 == ""s) _g_boolean_var_205 = 1; else _g_boolean_var_205 = 0; _g_boolean_var_205; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1445, ((const char*) ( __PRETTY_FUNCTION__)), "'" "*pit3 == \"\"s" "' should be TRUE" ); } while (0); |
1446 | ++pit3; |
1447 | g_assert_true(*pit3 == "abc"s)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_206 ; if (*pit3 == "abc"s) _g_boolean_var_206 = 1; else _g_boolean_var_206 = 0; _g_boolean_var_206; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1447, ((const char*) ( __PRETTY_FUNCTION__)), "'" "*pit3 == \"abc\"s" "' should be TRUE" ); } while (0); |
1448 | ++pit3; |
1449 | g_assert_true(pit3 == tokeniser3.cend())do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_207 ; if (pit3 == tokeniser3.cend()) _g_boolean_var_207 = 1; else _g_boolean_var_207 = 0; _g_boolean_var_207; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 1449, ((const char*) (__PRETTY_FUNCTION__)), "'" "pit3 == tokeniser3.cend()" "' should be TRUE" ); } while (0); |
1450 | |
1451 | /* And try an empty string, which should split into one empty token */ |
1452 | std::string str4{""s}; |
1453 | StringTokeniser tokeniser4{str4, ';'}; |
1454 | |
1455 | g_assert_cmpint(std::distance(tokeniser4.cbegin(), tokeniser4.cend()), ==, 1)do { gint64 __n1 = (std::distance(tokeniser4.cbegin(), tokeniser4 .cend())), __n2 = (1); if (__n1 == __n2) ; else g_assertion_message_cmpnum (((gchar*) 0), "../src/parser-test.cc", 1455, ((const char*) (__PRETTY_FUNCTION__)), "std::distance(tokeniser4.cbegin(), tokeniser4.cend())" " " "==" " " "1", (long double) __n1, "==", (long double) __n2 , 'i'); } while (0); |
1456 | auto pit4 = tokeniser4.cbegin(); |
1457 | g_assert_true(*pit4 == ""s)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_208 ; if (*pit4 == ""s) _g_boolean_var_208 = 1; else _g_boolean_var_208 = 0; _g_boolean_var_208; }), 1)) ; else g_assertion_message ( ((gchar*) 0), "../src/parser-test.cc", 1457, ((const char*) ( __PRETTY_FUNCTION__)), "'" "*pit4 == \"\"s" "' should be TRUE" ); } while (0); |
1458 | ++pit4; |
1459 | g_assert_true(pit4 == tokeniser4.cend())do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_209 ; if (pit4 == tokeniser4.cend()) _g_boolean_var_209 = 1; else _g_boolean_var_209 = 0; _g_boolean_var_209; }), 1)) ; else g_assertion_message (((gchar*) 0), "../src/parser-test.cc", 1459, ((const char*) (__PRETTY_FUNCTION__)), "'" "pit4 == tokeniser4.cend()" "' should be TRUE" ); } while (0); |
1460 | } |
1461 | |
1462 | static void |
1463 | test_seq_glue_sequence_builder(void) |
1464 | { |
1465 | /* This is sufficiently tested by being used in all the other tests, |
1466 | * but if there's anything remaining to be tested, do it here. |
1467 | */ |
1468 | } |
1469 | |
1470 | static void |
1471 | test_seq_glue_reply_builder(void) |
1472 | { |
1473 | /* Nothing to test here; ReplyBuilder is just a constructor for |
1474 | * SequenceBuilder. |
1475 | */ |
1476 | } |
1477 | |
1478 | int |
1479 | main(int argc, |
1480 | char* argv[]) |
1481 | { |
1482 | g_test_init(&argc, &argv, nullptr); |
1483 | |
1484 | g_test_add_func("/bte/parser/sequences/arg", test_seq_arg); |
1485 | g_test_add_func("/bte/parser/sequences/string", test_seq_string); |
1486 | g_test_add_func("/bte/parser/sequences/glue/arg", test_seq_glue_arg); |
1487 | g_test_add_func("/bte/parser/sequences/glue/string", test_seq_glue_string); |
1488 | g_test_add_func("/bte/parser/sequences/glue/string-tokeniser", test_seq_glue_string_tokeniser); |
1489 | g_test_add_func("/bte/parser/sequences/glue/sequence-builder", test_seq_glue_sequence_builder); |
1490 | g_test_add_func("/bte/parser/sequences/glue/reply-builder", test_seq_glue_reply_builder); |
1491 | g_test_add_func("/bte/parser/sequences/control", test_seq_control); |
1492 | g_test_add_func("/bte/parser/sequences/escape/invalid", test_seq_esc_invalid); |
1493 | g_test_add_func("/bte/parser/sequences/escape/charset/94", test_seq_esc_charset_94); |
1494 | g_test_add_func("/bte/parser/sequences/escape/charset/96", test_seq_esc_charset_96); |
1495 | g_test_add_func("/bte/parser/sequences/escape/charset/94^n", test_seq_esc_charset_94_n); |
1496 | g_test_add_func("/bte/parser/sequences/escape/charset/96^n", test_seq_esc_charset_96_n); |
1497 | g_test_add_func("/bte/parser/sequences/escape/charset/control", test_seq_esc_charset_control); |
1498 | g_test_add_func("/bte/parser/sequences/escape/charset/other", test_seq_esc_charset_other); |
1499 | g_test_add_func("/bte/parser/sequences/escape/nF", test_seq_esc_nF); |
1500 | g_test_add_func("/bte/parser/sequences/escape/F[pes]", test_seq_esc_Fpes); |
1501 | g_test_add_func("/bte/parser/sequences/escape/known", test_seq_esc_known); |
1502 | g_test_add_func("/bte/parser/sequences/csi", test_seq_csi); |
1503 | g_test_add_func("/bte/parser/sequences/csi/known", test_seq_csi_known); |
1504 | g_test_add_func("/bte/parser/sequences/csi/parameters", test_seq_csi_param); |
1505 | g_test_add_func("/bte/parser/sequences/csi/clear", test_seq_csi_clear); |
1506 | g_test_add_func("/bte/parser/sequences/csi/max", test_seq_csi_max); |
1507 | g_test_add_func("/bte/parser/sequences/sci", test_seq_sci); |
1508 | g_test_add_func("/bte/parser/sequences/sci/known", test_seq_sci_known); |
1509 | g_test_add_func("/bte/parser/sequences/dcs", test_seq_dcs); |
1510 | g_test_add_func("/bte/parser/sequences/dcs/known", test_seq_dcs_known); |
1511 | g_test_add_func("/bte/parser/sequences/osc", test_seq_osc); |
1512 | |
1513 | return g_test_run(); |
1514 | } |