aboutsummaryrefslogtreecommitdiffstats
path: root/libtests
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-04 22:28:12 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-07 01:14:52 +0200
commit0500d4347a6d31ef05fd860559e380c2e488c194 (patch)
tree26a22f65b7400d7fd26df5720fe2bbabd7b6de09 /libtests
parent05fda4afa289ef248804865d7648c9ac3ae75fbd (diff)
downloadqpdf-0500d4347a6d31ef05fd860559e380c2e488c194.tar.zst
JSON: add blob type that generates base64-encoded binary data
Diffstat (limited to 'libtests')
-rw-r--r--libtests/json.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/libtests/json.cc b/libtests/json.cc
index 3844222f..b386e6eb 100644
--- a/libtests/json.cc
+++ b/libtests/json.cc
@@ -1,6 +1,7 @@
#include <qpdf/assert_test.h>
#include <qpdf/JSON.hh>
+#include <qpdf/Pipeline.hh>
#include <qpdf/QPDFObjectHandle.hh>
#include <iostream>
@@ -113,6 +114,19 @@ test_main()
{"c", "[\n true\n]"},
};
assert(dvalue == xdvalue);
+ auto blob_data = [](Pipeline* p) {
+ *p << "\x01\x02\x03\x04\x05\xff\xfe\xfd\xfc\xfb";
+ };
+ JSON jblob = JSON::makeDictionary();
+ jblob.addDictionaryMember("normal", JSON::parse(R"("string")"));
+ jblob.addDictionaryMember("blob", JSON::makeBlob(blob_data));
+ // cSpell:ignore AQIDBAX
+ check(
+ jblob,
+ "{\n"
+ " \"blob\": \"AQIDBAX//v38+w==\",\n"
+ " \"normal\": \"string\"\n"
+ "}");
}
static void