fold basic and indefinite length tests in with the others; fix up Makefile
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 000d416..ae94a7f 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -104,6 +104,144 @@
Compare(Enc, (UsefulBufC){Expected, sizeof(Expected)})
+
+/*
+ Some very minimal tests.
+ */
+int basic_encode_test()
+{
+ // Very simple CBOR, a map with one boolean that is true in it
+ UsefulBuf_MakeStackUB(MemoryForEncoded, 100);
+ QCBOREncodeContext EC;
+
+ QCBOREncode_Init(&EC, MemoryForEncoded);
+
+ QCBOREncode_OpenMap(&EC);
+ QCBOREncode_AddBoolToMapN(&EC, 66, true);
+ QCBOREncode_CloseMap(&EC);
+
+ UsefulBufC Encoded;
+ if(QCBOREncode_Finish2(&EC, &Encoded)) {
+ return -3;
+ }
+
+
+ // Decode it and see that is right
+ QCBORDecodeContext DC;
+ QCBORItem Item;
+ QCBORDecode_Init(&DC, Encoded, QCBOR_DECODE_MODE_NORMAL);
+
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_MAP) {
+ return -1;
+ }
+
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_TRUE) {
+ return -1;
+ }
+
+ if(QCBORDecode_Finish(&DC)) {
+ return -2;
+ }
+
+
+ // Make another encoded message with the CBOR from the previous put into this one
+ UsefulBuf_MakeStackUB(MemoryForEncoded2, 100);
+ QCBOREncode_Init(&EC, MemoryForEncoded2);
+ QCBOREncode_OpenArray(&EC);
+ QCBOREncode_AddUInt64(&EC, 451);
+ QCBOREncode_AddEncoded(&EC, Encoded);
+ QCBOREncode_OpenMap(&EC);
+ QCBOREncode_AddEncodedToMapN(&EC, -70000, Encoded);
+ QCBOREncode_CloseMap(&EC);
+ QCBOREncode_CloseArray(&EC);
+
+ UsefulBufC Encoded2;
+ if(QCBOREncode_Finish2(&EC, &Encoded2)) {
+ return -3;
+ }
+ /*
+ [ // 0 1:3
+ 451, // 1 1:2
+ { // 1 1:2 2:1
+ 66: true // 2 1:1
+ },
+ { // 1 1:1 2:1
+ -70000: { // 2 1:1 2:1 3:1
+ 66: true // 3 XXXXXX
+ }
+ }
+ ]
+
+
+
+ 83 # array(3)
+ 19 01C3 # unsigned(451)
+ A1 # map(1)
+ 18 42 # unsigned(66)
+ F5 # primitive(21)
+ A1 # map(1)
+ 3A 0001116F # negative(69999)
+ A1 # map(1)
+ 18 42 # unsigned(66)
+ F5 # primitive(21)
+ */
+
+ // Decode it and see if it is OK
+ QCBORDecode_Init(&DC, Encoded2, QCBOR_DECODE_MODE_NORMAL);
+
+ // 0 1:3
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_ARRAY || Item.val.uCount != 3) {
+ return -1;
+ }
+
+ // 1 1:2
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_INT64 || Item.val.uint64 != 451) {
+ return -1;
+ }
+
+ // 1 1:2 2:1
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_MAP || Item.val.uCount != 1) {
+ return -1;
+ }
+
+ // 2 1:1
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_TRUE) {
+ return -1;
+ }
+
+ // 1 1:1 2:1
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_MAP || Item.val.uCount != 1) {
+ return -1;
+ }
+
+ // 2 1:1 2:1 3:1
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_MAP || Item.val.uCount != 1 || Item.uLabelType != QCBOR_TYPE_INT64 || Item.label.int64 != -70000) {
+ return -1;
+ }
+
+ // 3 XXXXXX
+ QCBORDecode_GetNext(&DC, &Item);
+ if(Item.uDataType != QCBOR_TYPE_TRUE || Item.uLabelType != QCBOR_TYPE_INT64 || Item.label.int64 != 66) {
+ return -1;
+ }
+
+ if(QCBORDecode_Finish(&DC)) {
+ return -2;
+ }
+
+ return 0;
+}
+
+
+
static const uint8_t pExpectedEncodedAll[] = {
0x98, 0x29, 0x66, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x32, 0xd8,