Merge branch 'develop' into feature/sax2

This commit is contained in:
Niels Lohmann 2018-03-05 16:16:43 +01:00
commit 86991d5204
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
5 changed files with 18 additions and 5 deletions

View file

@ -152,6 +152,10 @@ TEST_CASE("README", "[hide]")
j.push_back(1);
j.push_back(true);
// comparison
bool x = (j == "[\"foo\", 1, true]"_json); // true
CHECK(x == true);
// iterate the array
for (json::iterator it = j.begin(); it != j.end(); ++it)
{
@ -168,6 +172,7 @@ TEST_CASE("README", "[hide]")
const std::string tmp = j[0];
j[1] = 42;
bool foo = j.at(2);
CHECK(foo == true);
// other stuff
j.size(); // 3 entries
@ -175,9 +180,6 @@ TEST_CASE("README", "[hide]")
j.type(); // json::value_t::array
j.clear(); // the array is empty again
// comparison
bool x = (j == "[\"foo\", 1, true]"_json); // true
// create an object
json o;
o["foo"] = 23;
@ -257,17 +259,21 @@ TEST_CASE("README", "[hide]")
bool b1 = true;
json jb = b1;
bool b2 = jb;
CHECK(b2 == true);
// numbers
int i = 42;
json jn = i;
double f = jn;
CHECK(f == 42);
// etc.
std::string vs = js.get<std::string>();
bool vb = jb.get<bool>();
CHECK(vb == true);
int vi = jn.get<int>();
CHECK(vi == 42);
// etc.
}