Decode conformance for preferred serialization, CDE and dCBOR (#216)
Three conformance modes are added for decoding
- preferred serialization
- CDE
- dCBOR
This checks for sort ordering and duplicate labels when a map is decoded in CDE and dCBOR modes.
It does not support arrays and maps as map labels. They will error out, unless you use maps-as-arrays mode.
Conformance includes checking for shortest form of integers and floats and for dCBOR unification of floats and integers.
* start work on dCBOR decoding enforcement
* checkpoint
* Floating point conformane; ifdef for disabling
* Add more tests
* More dCBOR tests and conformance checks
* More test cases
* Bug fixes and more tests
* Check point stuff
* Map dup and sort order checking kind of working
* more work...
* Finish off UsefulInputBuf_Compare()
* Fix #ifdef fanout
* Fix warnings and #ifdef fan out
* sort & dup checking working and tested
* Fix test ifdef fan out
* Minor fix of one test case
* Another fan out fix
* backout map label checking; doc; test
* Stragglers
---------
Co-authored-by: Laurence Lundblade <lgl@securitytheory.com>
diff --git a/test/UsefulBuf_Tests.c b/test/UsefulBuf_Tests.c
index 0235466..6e47f3c 100644
--- a/test/UsefulBuf_Tests.c
+++ b/test/UsefulBuf_Tests.c
@@ -888,6 +888,31 @@
return "UIB SetBufferLength failed";
}
+ UsefulBufC CompCheck = UsefulBuf_FROM_SZ_LITERAL("abcd");
+ UsefulInputBuf_Init(&UIB, CompCheck);
+
+ if(UsefulInputBuf_Compare(&UIB, 0, 2, 2, 2) >= 0) {
+ return "UB 1 compared greater than UB2";
+ }
+ if(UsefulInputBuf_Compare(&UIB, 0, 2, 0, 2) != 0) {
+ return "UB1 and UB2 didn't compare equally";
+ }
+ if(UsefulInputBuf_Compare(&UIB, 2, 2, 0, 2) <= 0) {
+ return "UB2 compared less than UB1";
+ }
+ if(UsefulInputBuf_Compare(&UIB, 4, 1, 2, 2) <= 0) {
+ return "Off-the-end UB1 compared as less than UB2";
+ }
+ if(UsefulInputBuf_Compare(&UIB, 0, 5, 2, 2) <= 0) {
+ return "Off-the-end UB1 compared as less than UB2 (second)";
+ }
+ if(UsefulInputBuf_Compare(&UIB, 0, 2, 5, 1) >= 0) {
+ return "Off-the-end UB2 compared as less than UB2";
+ }
+ if(UsefulInputBuf_Compare(&UIB, 0, 2, 2, 3) >= 0) {
+ return "Off-the-end UB2 compared as less than UB2 (second)";
+ }
+
return NULL;
}