diff --git a/tests/cpp/common/test_json.cc b/tests/cpp/common/test_json.cc index 6974b9f07..ba3b12e33 100644 --- a/tests/cpp/common/test_json.cc +++ b/tests/cpp/common/test_json.cc @@ -545,10 +545,32 @@ TEST(Json, RoundTrip) { } auto t = i; - i+= static_cast(dist(&rng)); + i += static_cast(dist(&rng)); if (i < t) { break; } } } + +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(loaded))); + } else { + EXPECT_EQ(get(loaded), f); + } + }; + int64_t int32_max = static_cast(std::numeric_limits::max()); +#pragma omp parallel for schedule(static) + for (int64_t i = 0; i <= int32_max; ++i) { + test(static_cast(i)); + } +} } // namespace xgboost