Add an option to run brute-force test for JSON round-trip (#5804)

* Add an option to run brute-force test for JSON round-trip

* Apply reviewer's feedback

* Remove unneeded objects

* Parallel run.

* Max.

* Use signed 64-bit loop var, to support MSVC

* Add exhaustive test to CI

* Run JSON test in Win build worker

* Revert "Run JSON test in Win build worker"

This reverts commit c97b2c7dda37b3585b445d36961605b79552ca89.

* Revert "Add exhaustive test to CI"

This reverts commit c149c2ce9971a07a7289f9b9bc247818afd5a667.

Co-authored-by: fis <jm.yuan@outlook.com>
This commit is contained in:
Philip Hyunsu Cho 2020-06-17 23:46:02 -07:00 committed by GitHub
parent abdf894fcf
commit a67bc64819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -551,4 +551,26 @@ TEST(Json, RoundTrip) {
}
}
}
TEST(Json, DISABLED_RoundTripExhaustive) {
auto test = [](uint32_t i) {
float f;
std::memcpy(&f, &i, sizeof(f));
Json jf{f};
std::string str;
Json::Dump(jf, &str);
auto loaded = Json::Load({str.c_str(), str.size()});
if (XGBOOST_EXPECT(std::isnan(f), false)) {
EXPECT_TRUE(std::isnan(get<Number const>(loaded)));
} else {
EXPECT_EQ(get<Number const>(loaded), f);
}
};
int64_t int32_max = static_cast<int64_t>(std::numeric_limits<uint32_t>::max());
#pragma omp parallel for schedule(static)
for (int64_t i = 0; i <= int32_max; ++i) {
test(static_cast<uint32_t>(i));
}
}
} // namespace xgboost