diff options
author | Jay Berkenbilt <ejb@ql.org> | 2019-03-11 21:21:27 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2019-03-11 21:22:59 +0100 |
commit | da7c2c0ee90104524ed98a2370af0ea70a0f6d0d (patch) | |
tree | 6431dbf9d4421bb96cf1b4c2f957bcdc42b983de /libtests/json.cc | |
parent | d2260925f07e55de032ea93b50152b637e69049d (diff) | |
download | qpdf-da7c2c0ee90104524ed98a2370af0ea70a0f6d0d.tar.zst |
Fix json serialization for {x | -1 < x < 1} (fixes #308)
JSON serialization was preserving the value as presented, but JSON
doesn't accept decimal values without a 0 before the decimal point.
Diffstat (limited to 'libtests/json.cc')
-rw-r--r-- | libtests/json.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libtests/json.cc b/libtests/json.cc index 1a9123ad..e3086c18 100644 --- a/libtests/json.cc +++ b/libtests/json.cc @@ -3,7 +3,7 @@ #include <iostream> #include <assert.h> -static void check(JSON& j, std::string const& exp) +static void check(JSON const& j, std::string const& exp) { if (exp != j.unparse()) { @@ -69,6 +69,10 @@ static void test_main() " ],\n" " \"yes\": false\n" "}"); + check(QPDFObjectHandle::newReal("0.12").getJSON(), "0.12"); + check(QPDFObjectHandle::newReal(".34").getJSON(), "0.34"); + check(QPDFObjectHandle::newReal("-0.56").getJSON(), "-0.56"); + check(QPDFObjectHandle::newReal("-.78").getJSON(), "-0.78"); } static void check_schema(JSON& obj, JSON& schema, bool exp, |