Skip to content

Commit e27261e

Browse files
Parser/Validation: Add a test for good data
We had tests for cbor_validate* API for the errors it would find, but not that it did correctly reported CborNoError where no errors were expected. Signed-off-by: Thiago Macieira <[email protected]>
1 parent 9e97d07 commit e27261e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/parser/tst_parser.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ private slots:
106106
// validation & errors
107107
void checkedIntegers_data();
108108
void checkedIntegers();
109+
void validationValid_data() { arrays_data(); }
110+
void validationValid();
109111
void validation_data();
110112
void validation();
111113
void strictValidation_data();
@@ -1337,6 +1339,21 @@ void tst_Parser::checkedIntegers()
13371339
}
13381340
}
13391341

1342+
void tst_Parser::validationValid()
1343+
{
1344+
// verify that all valid data validate properly
1345+
QFETCH(QByteArray, data);
1346+
1347+
QString decoded;
1348+
ParserWrapper w;
1349+
CborError err = w.init(data);
1350+
QVERIFY2(!err, QByteArray("Got error \"") + cbor_error_string(err) + "\"");
1351+
1352+
QCOMPARE(cbor_value_validate_basic(&w.first), CborNoError);
1353+
QCOMPARE(cbor_value_validate(&w.first, CborValidateBasic), CborNoError);
1354+
QCOMPARE(cbor_value_validate(&w.first, CborValidateCompleteData), CborNoError);
1355+
}
1356+
13401357
void tst_Parser::validation_data()
13411358
{
13421359
addValidationColumns();

0 commit comments

Comments
 (0)