20#include <test/json/TestOutputSuite.h>
21#include <xrpl/beast/unit_test.h>
22#include <xrpl/json/Object.h>
49 TestOutputSuite::expectResult(expected);
71 root[
"hello"] =
"world";
73 root[
"awake"] =
false;
74 root[
"temperature"] = 98.6;
78 "{\"hello\":\"world\","
81 "\"temperature\":98.6}");
104 auto array = root.setArray(
"ar");
112 auto obj = root.setObject(
"obj");
113 obj[
"hello"] =
"world";
121 root[
"obj2"] = value;
127 "{\"ar\":[23,false,23.5],"
128 "\"obj\":{\"hello\":\"world\"},"
129 "\"obj2\":{\"h\":\"w\",\"f\":false}}";
131 "{\"ar\":[23,false,23.5],"
132 "\"obj\":{\"hello\":\"world\"},"
133 "\"obj2\":{\"f\":false,\"h\":\"w\"}}";
148 auto array = root.setArray(
"ar");
155 root.setObject(
"obj")[
"hello"] =
"world";
159 auto object = root.setObject(
"obj2");
160 object.set(
"h",
"w");
161 object.set(
"f",
false);
165 "{\"ar\":[23,false,23.5],"
166 "\"obj\":{\"hello\":\"world\"},"
167 "\"obj2\":{\"h\":\"w\",\"f\":false}}");
174 setup(
"object failure assign");
176 auto obj = root.setObject(
"o1");
180 setup(
"object failure object");
182 auto obj = root.setObject(
"o1");
186 setup(
"object failure Array");
188 auto obj = root.setArray(
"o1");
197 setup(
"array failure append");
199 auto array = root.setArray(
"array");
200 auto subarray = array.appendArray();
201 auto fail = [&]() { array.append(
"fail"); };
205 setup(
"array failure appendArray");
207 auto array = root.setArray(
"array");
208 auto subarray = array.appendArray();
209 auto fail = [&]() { array.appendArray(); };
213 setup(
"array failure appendObject");
215 auto array = root.setArray(
"array");
216 auto subarray = array.appendArray();
217 auto fail = [&]() { array.appendObject(); };
225 setup(
"repeating keys");
227 root.set(
"foo",
"bar");
230 auto set_again = [&]() { root.set(
"foo",
"bar"); };
255BEAST_DEFINE_TESTSUITE(JsonObject, ripple_basics,
ripple);
void setup(std::string const &testName)
void expectResult(std::string const &expected)
std::unique_ptr< WriterObject > writerObject_
void run() override
Runs the suite.
Represents a JSON object being written to a Writer.
void pass()
Record a successful test condition.
testcase_t testcase
Memberspace for declaring test cases.
void fail(String const &reason, char const *file, int line)
Record a failure.
bool expectException(Functor f, std::string const &message="")
JSON (JavaScript Object Notation).
WriterObject stringWriterObject(std::string &)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.