summaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-11-13 15:33:56 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-11-13 15:33:56 +0100
commitb3f9b25d53b1bd1fc83e8a291ae40b84d02a4478 (patch)
tree64a170a55f6f9b0c949339511db77b80abeb61f9 /src/app
parent36316c2e4a9dbeab28b97fa18fefc37eed4a6782 (diff)
prototest: add ubjson
Diffstat (limited to 'src/app')
-rw-r--r--src/app/prototest/Makefile.inc2
-rw-r--r--src/app/prototest/main.cc30
2 files changed, 31 insertions, 1 deletions
diff --git a/src/app/prototest/Makefile.inc b/src/app/prototest/Makefile.inc
index d3dad26..36cfb49 100644
--- a/src/app/prototest/Makefile.inc
+++ b/src/app/prototest/Makefile.inc
@@ -23,7 +23,7 @@ endif
ifeq (${prototest_ubjson}, 1)
COMMON_FLAGS += -DPROTOTEST_UBJSON
- CXX_TARGETS += src/lib/ubjson/ubjr.cc src/lib/ubjson/ubjw.cc
+ C_TARGETS += src/lib/ubjson/ubjr.c src/lib/ubjson/ubjw.c
INCLUDES += -Iinclude/lib/ubjson
endif
diff --git a/src/app/prototest/main.cc b/src/app/prototest/main.cc
index aebfaea..c1d8359 100644
--- a/src/app/prototest/main.cc
+++ b/src/app/prototest/main.cc
@@ -17,6 +17,9 @@
#include <pb_encode.h>
#include <pb_decode.h>
#endif
+#ifdef PROTOTEST_UBJSON
+#include "ubj.h"
+#endif
#ifdef PROTOTEST_XDR
#include "object/stdbuf.h"
#include "object/xdrstream.h"
@@ -149,6 +152,33 @@ void loop(void)
#endif
/*
+ * UBJSON
+ */
+
+#ifdef PROTOTEST_UBJSON
+
+ uint8_t buf[128];
+ for (unsigned int i = 0; i < 128; i++) {
+ buf[i] = 0;
+ }
+
+ ubjw_context_t* ctx = ubjw_open_memory(buf, buf + sizeof(buf));
+ ubjw_begin_array(ctx, UBJ_MIXED, 0);
+ ubjw_write_int16(ctx, ts);
+ ubjw_write_string(ctx, "Noot Noot");
+ ubjw_end(ctx);
+
+ kout << "ubjr_close_context: " << ubjw_close_context(ctx) << endl;
+
+ kout << "ubjr is " << hex;
+ for (unsigned int i = 0; i < 128; i++) {
+ kout << (uint8_t)buf[i];
+ }
+ kout << endl;
+
+#endif
+
+ /*
* Common
*/