diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-06-18 21:39:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-20 21:25:11 +0200 |
commit | cb95276e6e6bf12a1c06d5c252551e55c788fcb2 (patch) | |
tree | 9e54d9ddbd03f02f508af48ce8dce02d5c83a277 /tools/qa | |
parent | 292d9519bd368db69920cf0f8b94e0e51c3d14a1 (diff) |
use JsonWriter for the rest of ITiledRenderable
and fix bug in buffer reallacotion where mPos pointing
at the beginning of the new buffer instead of at the
correct index inside it.
Change-Id: Ie1ffaa176f6165e2cec85c93adc945312eff38e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96650
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools/qa')
-rw-r--r-- | tools/qa/cppunit/test_json_writer.cxx | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/tools/qa/cppunit/test_json_writer.cxx b/tools/qa/cppunit/test_json_writer.cxx index e27afc95f712..6a2cc7813574 100644 --- a/tools/qa/cppunit/test_json_writer.cxx +++ b/tools/qa/cppunit/test_json_writer.cxx @@ -30,12 +30,19 @@ public: virtual void setUp() override {} void test1(); + void test2(); CPPUNIT_TEST_SUITE(JsonWriterTest); CPPUNIT_TEST(test1); + CPPUNIT_TEST(test2); CPPUNIT_TEST_SUITE_END(); }; +struct Free +{ + void operator()(void* p) const { std::free(p); } +}; + void JsonWriterTest::test1() { tools::JsonWriter aJson; @@ -48,10 +55,6 @@ void JsonWriterTest::test1() aJson.put("int", 12); } - struct Free - { - void operator()(void* p) const { std::free(p); } - }; std::unique_ptr<char, Free> result(aJson.extractData()); CPPUNIT_ASSERT_EQUAL(std::string("{ \"node\": { \"oustring\": \"val1\", \"ostring\": \"val2\", " @@ -59,6 +62,33 @@ void JsonWriterTest::test1() std::string(result.get())); } +void JsonWriterTest::test2() +{ + tools::JsonWriter aJson; + + { + auto testNode = aJson.startNode("node"); + aJson.put("field1", OUString("val1")); + aJson.put("field2", OUString("val2")); + { + auto testNode2 = aJson.startNode("node"); + aJson.put("field3", OUString("val3")); + { + auto testNode3 = aJson.startNode("node"); + aJson.put("field4", OUString("val4")); + aJson.put("field5", OUString("val5")); + } + } + } + + std::unique_ptr<char, Free> result(aJson.extractData()); + + CPPUNIT_ASSERT_EQUAL(std::string("{ \"node\": { \"field1\": \"val1\", \"field2\": \"val2\", " + "\"node\": { \"field3\": \"val3\", \"node\": { \"field4\": " + "\"val4\", \"field5\": \"val5\"}}}}"), + std::string(result.get())); +} + CPPUNIT_TEST_SUITE_REGISTRATION(JsonWriterTest); } |