Big number, big float and decimal fraction rework
New set of functions for big numbers, big floats and decimal fractions to have naming consistency. The old ones are still supported.
This is backwards compatible with QBOR v1. Previous work on v2 big numbers were not. This regains compatibility.
Offset of one for negative numbers is consistency supported for big numbers, big floats and decimal fractions.
Support for preferred serialization of big numbers including big floats and decimal fraction. No-preferred and raw options are provided too.
Prefer "BigNumber" to "bignum" and variants in function and variable naming
Add UsefulBuf_SkipLeading()
Separate definition of QCBORExpAndMantissa for readability of code.
* Big number rework (check point; not tested yet)
* Lots more reworking; tests passing (checkpoint)
* More big number rework
* Big number documentation and code tidy
* documentation and tidy
* GetNext handles 65 bit negs in exp and float...
* Fixes -- tests are passing now
* Fix disabled tags
* Check point; big function rename and fan out
* Lots of cross checking and small fixes
* Fix full test fan out
* Remove some redundant/left-over commas
* relocate expAndMantissa definition for clarity
---------
Co-authored-by: Laurence Lundblade <lgl@securitytheory.com>
diff --git a/test/UsefulBuf_Tests.c b/test/UsefulBuf_Tests.c
index 338e6db..ae3862c 100644
--- a/test/UsefulBuf_Tests.c
+++ b/test/UsefulBuf_Tests.c
@@ -704,6 +704,31 @@
return "Failed to find 4";
}
+ UsefulBufC Substring;
+ Substring = UsefulBuf_SkipLeading(UsefulBuf_FromSZ("xxyyzz"), 'x');
+ if(UsefulBuf_Compare(Substring, UsefulBuf_FromSZ("yyzz"))) {
+ return "SkipLeading didn't skip";
+ }
+
+ Substring = UsefulBuf_SkipLeading(UsefulBuf_FromSZ("xxyyzz"), 'y');
+ if(UsefulBuf_Compare(Substring, UsefulBuf_FromSZ("xxyyzz"))) {
+ return "SkipLeading skipped";
+ }
+
+ Substring = UsefulBuf_SkipLeading(UsefulBuf_FromSZ("qqq"), 'q');
+ if(UsefulBuf_Compare(Substring, UsefulBuf_FromSZ(""))) {
+ return "SkipLeading didn't return empty";
+ }
+
+ Substring = UsefulBuf_SkipLeading(UsefulBuf_FromSZ("x"), 'x');
+ if(UsefulBuf_Compare(Substring, UsefulBuf_FromSZ(""))) {
+ return "SkipLeading didn't return empty";
+ }
+
+ Substring = UsefulBuf_SkipLeading(UsefulBuf_FromSZ("xxxxxxxxxxxx"), 'x');
+ if(UsefulBuf_Compare(Substring, UsefulBuf_FromSZ(""))) {
+ return "SkipLeading didn't return empty";
+ }
const uint8_t pB[] = {0x01, 0x02, 0x03};
UsefulBufC Boo = UsefulBuf_FROM_BYTE_ARRAY_LITERAL(pB);