Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/cborpretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ static const char *resolve_indicator(const CborValue *it, int flags)
return no_indicator;

/* determine whether to show anything */
if ((flags & CborPrettyIndicateIndeterminateLength) &&
additional_information == IndefiniteLength)
return indicators[IndefiniteLength - Value8Bit];
if (additional_information == IndefiniteLength) {
if (flags & CborPrettyIndicateIndeterminateLength)
return indicators[IndefiniteLength - Value8Bit];
return no_indicator;
}
if ((flags & CborPrettyIndicateOverlongNumbers) == 0)
return no_indicator;

Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if(Qt6_FOUND)
add_subdirectory(cpp)
add_subdirectory(encoder)
add_subdirectory(parser)
add_subdirectory(pretty)
if(WITH_CBOR2JSON)
add_subdirectory(tojson)
endif()
Expand Down
4 changes: 4 additions & 0 deletions tests/parser/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,14 @@ void addValidationData(size_t minInvalid = ~size_t(0))
QTest::newRow("array-no-break2") << raw("\x81\x9f\0") << 0 << CborErrorUnexpectedEOF;
QTest::newRow("map-no-break1") << raw("\x81\xbf") << 0 << CborErrorUnexpectedEOF;
QTest::newRow("map-no-break2") << raw("\x81\xbf\0\0") << 0 << CborErrorUnexpectedEOF;
QTest::newRow("array-element-is-break") << raw("\x81\x81\xff") << 0 << CborErrorUnexpectedBreak;
QTest::newRow("map-key-is-break") << raw("\x81\xa1\xff\0") << 0 << CborErrorUnexpectedBreak;
QTest::newRow("map-value-is-break") << raw("\x81\xa1\0\xff") << 0 << CborErrorUnexpectedBreak;
QTest::newRow("map-break-after-key") << raw("\x81\xbf\0\xff") << 0 << CborErrorUnexpectedBreak;
QTest::newRow("map-break-after-second-key") << raw("\x81\xbf\x64xyzw\x04\x00\xff") << 0 << CborErrorUnexpectedBreak;
QTest::newRow("map-break-after-value-tag") << raw("\x81\xbf\0\xc0\xff") << 0 << CborErrorUnexpectedBreak;
QTest::newRow("map-break-after-value-tag2") << raw("\x81\xbf\0\xd8\x20\xff") << 0 << CborErrorUnexpectedBreak;
QTest::newRow("tagged-break") << raw("\xc0\xff") << 0 << CborErrorUnexpectedBreak;

// check for pointer additions wrapping over the limit of the address space
auto wraparoundError = [minInvalid](uint64_t encodedSize) {
Expand Down
3 changes: 3 additions & 0 deletions tests/pretty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (C) 2026 Intel Corporation
# SPDX-License-Identifier: MIT
tinycbor_add_qtest(tst_pretty tst_pretty.cpp)
Loading
Loading