-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add short json support * logic is done * bug fixes * fix crash on passing paramenters * enhance code complexity, few bug fixes * bug fixes * update documentation * fix typo * fix json crash when passing array of objects * update documentation * add unit tests * fix naming * bug fixes, add more tests, and improve SOG * bug fixes, more tests * add space removal system * add space removal system * bug fixes, more tests * bug fixes * finalizing tests, bug fixes * more tests * fix double quotes read/write * bug fixes * update adding missing keys call for better readability * add tests for JSON readers and parsers * fix short JSON tests name * last commit * add deleted files * readd deleted files * few improvements * improve tests --------- Co-authored-by: saifkandil <saifsaalaheldeen2002@gmail.com>
- Loading branch information
Showing
14 changed files
with
1,338 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#if !defined(JSON_READER_TEST_CPP) | ||
#define JSON_READER_TEST_CPP | ||
#endif // JSON_READER_TEST_CPP | ||
|
||
#include "Universal_System/Extensions/Json/json_reader.cpp" | ||
#include "Universal_System/Extensions/Json/json_value.cpp" | ||
#include "Universal_System/Extensions/Json/json_writer.cpp" | ||
#include "Universal_System/Extensions/Json/reader.h" | ||
#include "Universal_System/Extensions/Json/value.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <string> | ||
|
||
TEST(JSONTest, TestSpaces) { | ||
std::string data{ | ||
" { \"0\":\t{ \"0\": \" s \ttr\n \", \"1\": \n8 } , \"1\"\r\n:{\"0\":true,\"1\" : -4 } ,\r\"2\":\nfalse}"}; | ||
Json::Value root; | ||
Json::Reader reader; | ||
bool parsingSuccessful = reader.parse(std::string(data), root); | ||
|
||
EXPECT_TRUE(root.isObject()); | ||
ASSERT_EQ(parsingSuccessful, true); | ||
} | ||
|
||
TEST(JSONTest, TestPassingArrayOfJSONObjects) { | ||
std::string data{ | ||
"[{\"0\":{\"0\":{\"0\":1,\"1\":4},\"1\":[{\"0\":1,\"1\":4},{\"0\":1,\"1\":4}],\"2\":{\"0\":1,\"1\":4}," | ||
"\"3\":7,\"4\":{\"0\":1,\"1\":4},\"5\":[{\"0\":1,\"1\":4},{\"0\":1,\"1\":4},{\"0\":1,\"1\":4}]},\"1\":{" | ||
"\"0\":1,\"1\":4},\"2\":5},{\"0\":1,\"1\":4}]"}; | ||
Json::Value root; | ||
Json::Reader reader; | ||
bool parsingSuccessful = reader.parse(std::string(data), root); | ||
|
||
EXPECT_TRUE(root.isArray()); | ||
ASSERT_EQ(parsingSuccessful, true); | ||
} | ||
|
||
TEST(JSONTest, TestPassingSingleJSONObject) { | ||
std::string data{ | ||
"{\"0\":{\"0\":{\"0\":1,\"1\":4},\"1\":[{\"0\":1,\"1\":4},{\"0\":1,\"1\":4}],\"2\":{\"0\":1,\"1\":4},\"3\":" | ||
"7,\"4\":{\"0\":1,\"1\":4},\"5\":[{\"0\":1,\"1\":4},{\"0\":1,\"1\":4},{\"0\":1,\"1\":4}]},\"1\":{\"0\":1," | ||
"\"1\":4},\"2\":5}"}; | ||
Json::Value root; | ||
Json::Reader reader; | ||
bool parsingSuccessful = reader.parse(std::string(data), root); | ||
|
||
EXPECT_TRUE(root.isObject()); | ||
ASSERT_EQ(parsingSuccessful, true); | ||
} | ||
|
||
TEST(JSONTest, TestPassingExtensiveGeneralInput) { | ||
std::string data{ | ||
"{" | ||
"\"0\":{" | ||
"\"0\":{" | ||
"\"0\":\"] ][dm895vmfv_,,\"," | ||
"\"1\":true" | ||
"}," | ||
"\"1\":[" | ||
"{" | ||
"\"0\":false," | ||
"\"1\":-46.8" | ||
"}," | ||
"{" | ||
"\"0\":\"dsjdjk\"," | ||
"\"1\":65890.3" | ||
"}" | ||
"]," | ||
"\"2\":{" | ||
"\"0\":-77777777777," | ||
"\"1\":44444444" | ||
"}," | ||
"\"3\":true," | ||
"\"4\":{" | ||
"\"0\":\"\"," | ||
"\"1\":4567.1" | ||
"}," | ||
"\"5\":[" | ||
"{" | ||
"\"0\":13," | ||
"\"1\":0" | ||
"}," | ||
"{" | ||
"\"0\":\"ty \"," | ||
"\"1\":true" | ||
"}," | ||
"{" | ||
"\"0\":133," | ||
"\"1\":\"fghkll::\"" | ||
"}" | ||
"]" | ||
"}," | ||
"\"1\":{" | ||
"\"0\":1.6678," | ||
"\"1\":4" | ||
"}," | ||
"\"2\":5" | ||
"}"}; | ||
Json::Value root; | ||
Json::Reader reader; | ||
bool parsingSuccessful = reader.parse(std::string(data), root); | ||
|
||
EXPECT_TRUE(root.isObject()); | ||
ASSERT_EQ(parsingSuccessful, true); | ||
} |
Oops, something went wrong.