@@ -101,6 +101,8 @@ CborError parseOne(CborValue *it, QString *parsed)
101
101
char *buffer;
102
102
size_t size;
103
103
104
+ int flags = CborPrettyShowStringFragments;
105
+
104
106
setlocale (LC_ALL, " C" );
105
107
#ifdef Q_CC_MSVC
106
108
// no open_memstream, so use a temporary file
@@ -110,7 +112,7 @@ CborError parseOne(CborValue *it, QString *parsed)
110
112
FILE *f = fopen (QFile::encodeName (tmp.fileName ()), " w+" );
111
113
if (!f)
112
114
return CborErrorIO;
113
- err = cbor_value_to_pretty_advance (f, it);
115
+ err = cbor_value_to_pretty_advance_flags (f, it, flags );
114
116
size = ftell (f);
115
117
rewind (f);
116
118
@@ -119,7 +121,7 @@ CborError parseOne(CborValue *it, QString *parsed)
119
121
fclose (f);
120
122
#else
121
123
FILE *f = open_memstream (&buffer, &size);
122
- err = cbor_value_to_pretty_advance (f, it);
124
+ err = cbor_value_to_pretty_advance_flags (f, it, flags );
123
125
fclose (f);
124
126
#endif
125
127
@@ -130,8 +132,6 @@ CborError parseOne(CborValue *it, QString *parsed)
130
132
131
133
CborError parseOneChunk (CborValue *it, QString *parsed)
132
134
{
133
- // we can't use the cborpretty.c API here because it uses
134
- // cbor_value_advance_fixed and cbor_value_dup_xxxx_string
135
135
CborError err;
136
136
CborType ourType = cbor_value_get_type (it);
137
137
if (ourType == CborByteStringType) {
@@ -397,18 +397,18 @@ void addStringsData()
397
397
QTest::newRow (" textstring5*8" ) << raw (" \x7b\0\0\0\0\0\0\0\x05 Hello" ) << " \" Hello\" " ;
398
398
399
399
// strings with undefined length
400
- QTest::newRow (" _emptybytestring" ) << raw (" \x5f\xff " ) << " h'' " ;
401
- QTest::newRow (" _emptytextstring" ) << raw (" \x7f\xff " ) << " \"\" " ;
402
- QTest::newRow (" _emptybytestring2" ) << raw (" \x5f\x40\xff " ) << " h''" ;
403
- QTest::newRow (" _emptytextstring2" ) << raw (" \x7f\x60\xff " ) << " \"\" " ;
404
- QTest::newRow (" _emptybytestring3" ) << raw (" \x5f\x40\x40\xff " ) << " h''" ;
405
- QTest::newRow (" _emptytextstring3" ) << raw (" \x7f\x60\x60\xff " ) << " \"\" " ;
406
- QTest::newRow (" _bytestring5*2" ) << raw (" \x5f\x43 Hel\x42 lo\xff " ) << " h'48656c6c6f' " ;
407
- QTest::newRow (" _textstring5*2" ) << raw (" \x7f\x63 Hel\x62 lo\xff " ) << " \" Hello \" " ;
408
- QTest::newRow (" _bytestring5*5" ) << raw (" \x5f\x41 H\x41 " " e\x41 l\x41 l\x41 o\xff " ) << " h'48656c6c6f' " ;
409
- QTest::newRow (" _textstring5*5" ) << raw (" \x7f\x61 H\x61 " " e\x61 l\x61 l\x61 o\xff " ) << " \" Hello \" " ;
410
- QTest::newRow (" _bytestring5*6" ) << raw (" \x5f\x41 H\x41 " " e\x40\x41 l\x41 l\x41 o\xff " ) << " h'48656c6c6f' " ;
411
- QTest::newRow (" _textstring5*6" ) << raw (" \x7f\x61 H\x61 " " e\x61 l\x60\x61 l\x61 o\xff " ) << " \" Hello \" " ;
400
+ QTest::newRow (" _emptybytestring" ) << raw (" \x5f\xff " ) << " (_ ) " ;
401
+ QTest::newRow (" _emptytextstring" ) << raw (" \x7f\xff " ) << " (_ ) " ;
402
+ QTest::newRow (" _emptybytestring2" ) << raw (" \x5f\x40\xff " ) << " (_ h'') " ;
403
+ QTest::newRow (" _emptytextstring2" ) << raw (" \x7f\x60\xff " ) << " (_ \"\" ) " ;
404
+ QTest::newRow (" _emptybytestring3" ) << raw (" \x5f\x40\x40\xff " ) << " (_ h'', h'') " ;
405
+ QTest::newRow (" _emptytextstring3" ) << raw (" \x7f\x60\x60\xff " ) << " (_ \"\" , \"\" ) " ;
406
+ QTest::newRow (" _bytestring5*2" ) << raw (" \x5f\x43 Hel\x42 lo\xff " ) << " (_ h'48656c', h'6c6f') " ;
407
+ QTest::newRow (" _textstring5*2" ) << raw (" \x7f\x63 Hel\x62 lo\xff " ) << " (_ \" Hel \" , \" lo \" ) " ;
408
+ QTest::newRow (" _bytestring5*5" ) << raw (" \x5f\x41 H\x41 " " e\x41 l\x41 l\x41 o\xff " ) << " (_ h'48', h'65', h'6c', h'6c', h'6f') " ;
409
+ QTest::newRow (" _textstring5*5" ) << raw (" \x7f\x61 H\x61 " " e\x61 l\x61 l\x61 o\xff " ) << " (_ \" H \" , \" e \" , \" l \" , \" l \" , \" o \" ) " ;
410
+ QTest::newRow (" _bytestring5*6" ) << raw (" \x5f\x41 H\x41 " " e\x40\x41 l\x41 l\x41 o\xff " ) << " (_ h'48', h'65', h'', h'6c', h'6c', h'6f') " ;
411
+ QTest::newRow (" _textstring5*6" ) << raw (" \x7f\x61 H\x61 " " e\x61 l\x60\x61 l\x61 o\xff " ) << " (_ \" H \" , \" e \" , \" l \" , \"\" , \" l \" , \" o \" ) " ;
412
412
}
413
413
414
414
void tst_Parser::strings_data ()
@@ -763,7 +763,7 @@ void tst_Parser::mapsAndArrays()
763
763
764
764
// mixed with indeterminate length strings
765
765
compareOneSize (-1 , " \xbf\1\x9f " + data + " \xff\x65 Hello\xbf " + data + " \x7f\xff\xff\xff " ,
766
- " {_ 1: [_ " + expected + " ], \" Hello\" : {_ " + expected + " : \"\" }}" );
766
+ " {_ 1: [_ " + expected + " ], \" Hello\" : {_ " + expected + " : (_ ) }}" );
767
767
}
768
768
769
769
void tst_Parser::chunkedString_data ()
0 commit comments