diff --git a/tests/cpp/c_api/test_c_api.cc b/tests/cpp/c_api/test_c_api.cc index 9a63d51308ec..205e5f561919 100644 --- a/tests/cpp/c_api/test_c_api.cc +++ b/tests/cpp/c_api/test_c_api.cc @@ -8,10 +8,11 @@ #include #include -#include // for array -#include // std::size_t -#include // std::numeric_limits -#include // std::string +#include // for array +#include // std::size_t +#include // std::filesystem +#include // std::numeric_limits +#include // std::string #include #include "../../../src/c_api/c_api_error.h" @@ -162,7 +163,7 @@ TEST(CAPI, ConfigIO) { TEST(CAPI, JsonModelIO) { size_t constexpr kRows = 10; size_t constexpr kCols = 10; - dmlc::TemporaryDirectory tempdir; + auto tempdir = std::filesystem::temp_directory_path(); auto p_dmat = RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix(); std::vector> mat {p_dmat}; @@ -178,19 +179,19 @@ TEST(CAPI, JsonModelIO) { learner->UpdateOneIter(0, p_dmat); BoosterHandle handle = learner.get(); - std::string modelfile_0 = tempdir.path + "/모델_0.json"; - XGBoosterSaveModel(handle, modelfile_0.c_str()); - XGBoosterLoadModel(handle, modelfile_0.c_str()); + auto modelfile_0 = tempdir / std::filesystem::u8path(u8"모델_0.json"); + XGBoosterSaveModel(handle, modelfile_0.u8string().c_str()); + XGBoosterLoadModel(handle, modelfile_0.u8string().c_str()); bst_ulong num_feature {0}; ASSERT_EQ(XGBoosterGetNumFeature(handle, &num_feature), 0); ASSERT_EQ(num_feature, kCols); - std::string modelfile_1 = tempdir.path + "/model_1.json"; - XGBoosterSaveModel(handle, modelfile_1.c_str()); + auto modelfile_1 = tempdir / "model_1.json"; + XGBoosterSaveModel(handle, modelfile_1.u8string().c_str()); - auto model_str_0 = common::LoadSequentialFile(modelfile_0); - auto model_str_1 = common::LoadSequentialFile(modelfile_1); + auto model_str_0 = common::LoadSequentialFile(modelfile_0.u8string()); + auto model_str_1 = common::LoadSequentialFile(modelfile_1.u8string()); ASSERT_EQ(model_str_0.front(), '{'); ASSERT_EQ(model_str_0, model_str_1);