Commit 82c1888d authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Adding json parser failure/pass and benchmark tests.

parent 83f614eb
Pipeline #96067 failed with stages
in 77 minutes and 29 seconds
[-0.0]
\ No newline at end of file
[1.2345]
\ No newline at end of file
[-1.2345]
\ No newline at end of file
[5e-324]
\ No newline at end of file
[2.225073858507201e-308]
\ No newline at end of file
[2.2250738585072014e-308]
\ No newline at end of file
[1.7976931348623157e308]
\ No newline at end of file
#include "gtest/gtest.h"
#include "radixbug/bug.hh"
#include "radixcore/json.hh"
#include "radixcore/system.hh"
......@@ -230,3 +231,108 @@ TEST(JSONParser, parse_from_stream)
EXPECT_EQ("string missing closing quote at line 1 column 5", errorMsg);
}
}
bool parse_and_test(const std::string& file)
{
std::cout << "PARSE_AND_TEST(" << file << ")" << std::endl;
Timer benchmark_timer;
JSONParser parser;
std::string filename =
to_native_path(dirname(__FILE__) + "/testfiles/" + file);
std::cout << "Test file: " << filename << std::endl;
bool benchmark = (file.substr(0, 4).compare("benc") == 0);
if (benchmark)
{
benchmark_timer.start();
}
bool success = parser.parse_from_file(filename);
if (benchmark) benchmark_timer.stop();
bool return_success = false;
// check if failure is expected
if (file.substr(0, 4).compare("fail") == 0)
{
return_success = !success;
}
if (!return_success)
{
// dump the json error
std::cout << parser.last_error() << std::endl;
}
if (benchmark)
{
std::cout << "Benchmark(" << file
<< ") timing: " << (benchmark_timer.duration() / 1e9)
<< " seconds" << std::endl;
}
return return_success;
}
TEST(JSONParser, JSONChecker)
{
// EXPECT_TRUE(parse_and_test("fail01_EXCLUDE.json"));
EXPECT_TRUE(parse_and_test("fail02.json"));
EXPECT_TRUE(parse_and_test("fail03.json"));
EXPECT_TRUE(parse_and_test("fail04.json"));
EXPECT_TRUE(parse_and_test("fail05.json"));
EXPECT_TRUE(parse_and_test("fail06.json"));
EXPECT_TRUE(parse_and_test("fail07.json"));
EXPECT_TRUE(parse_and_test("fail08.json"));
EXPECT_TRUE(parse_and_test("fail09.json"));
EXPECT_TRUE(parse_and_test("fail10.json"));
EXPECT_TRUE(parse_and_test("fail11.json"));
EXPECT_TRUE(parse_and_test("fail12.json"));
EXPECT_TRUE(parse_and_test("fail13.json"));
EXPECT_TRUE(parse_and_test("fail14.json"));
EXPECT_TRUE(parse_and_test("fail15.json"));
EXPECT_TRUE(parse_and_test("fail16.json"));
EXPECT_TRUE(parse_and_test("fail17.json"));
// EXPECT_TRUE(parse_and_test("fail18_EXCLUDE.json"));
EXPECT_TRUE(parse_and_test("fail19.json"));
EXPECT_TRUE(parse_and_test("fail20.json"));
EXPECT_TRUE(parse_and_test("fail21.json"));
EXPECT_TRUE(parse_and_test("fail22.json"));
EXPECT_TRUE(parse_and_test("fail23.json"));
EXPECT_TRUE(parse_and_test("fail24.json"));
EXPECT_TRUE(parse_and_test("fail25.json"));
EXPECT_TRUE(parse_and_test("fail26.json"));
EXPECT_TRUE(parse_and_test("fail27.json"));
EXPECT_TRUE(parse_and_test("fail28.json"));
EXPECT_TRUE(parse_and_test("fail29.json"));
EXPECT_TRUE(parse_and_test("fail30.json"));
EXPECT_TRUE(parse_and_test("fail31.json"));
EXPECT_TRUE(parse_and_test("fail32.json"));
EXPECT_TRUE(parse_and_test("fail33.json"));
EXPECT_TRUE(parse_and_test("pass01.json"));
EXPECT_TRUE(parse_and_test("pass02.json"));
EXPECT_TRUE(parse_and_test("pass03.json"));
// EXPECT_TRUE(parse_and_test("roundtrip01.json"));
// EXPECT_TRUE(parse_and_test("roundtrip02.json"));
// EXPECT_TRUE(parse_and_test("roundtrip03.json"));
// EXPECT_TRUE(parse_and_test("roundtrip04.json"));
// EXPECT_TRUE(parse_and_test("roundtrip05.json"));
// EXPECT_TRUE(parse_and_test("roundtrip06.json"));
// EXPECT_TRUE(parse_and_test("roundtrip07.json"));
// EXPECT_TRUE(parse_and_test("roundtrip08.json"));
// EXPECT_TRUE(parse_and_test("roundtrip09.json"));
// EXPECT_TRUE(parse_and_test("roundtrip10.json"));
// EXPECT_TRUE(parse_and_test("roundtrip11.json"));
// EXPECT_TRUE(parse_and_test("roundtrip12.json"));
// EXPECT_TRUE(parse_and_test("roundtrip13.json"));
// EXPECT_TRUE(parse_and_test("roundtrip14.json"));
// EXPECT_TRUE(parse_and_test("roundtrip15.json"));
// EXPECT_TRUE(parse_and_test("roundtrip16.json"));
// EXPECT_TRUE(parse_and_test("roundtrip17.json"));
// EXPECT_TRUE(parse_and_test("roundtrip18.json"));
// EXPECT_TRUE(parse_and_test("roundtrip19.json"));
// EXPECT_TRUE(parse_and_test("roundtrip20.json"));
// EXPECT_TRUE(parse_and_test("roundtrip21.json"));
// EXPECT_TRUE(parse_and_test("roundtrip22.json"));
// EXPECT_TRUE(parse_and_test("roundtrip23.json"));
// EXPECT_TRUE(parse_and_test("roundtrip24.json"));
// EXPECT_TRUE(parse_and_test("roundtrip25.json"));
// EXPECT_TRUE(parse_and_test("roundtrip26.json"));
// EXPECT_TRUE(parse_and_test("roundtrip27.json"));
EXPECT_TRUE(parse_and_test("benchmark_canada.json"));
EXPECT_TRUE(parse_and_test("benchmark_citm_catalog.json"));
EXPECT_TRUE(parse_and_test("benchmark_twitter.json"));
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment