Utilities and cleanups for socket. (#9576)

- Use c++-17 nodiscard and nested ns.
- Add bind method to socket.
- Remove rabit parameters.
This commit is contained in:
Jiaming Yuan
2023-09-14 01:41:42 +08:00
committed by GitHub
parent 5abe50ff8c
commit b438d684d2
12 changed files with 187 additions and 75 deletions

View File

@@ -4,6 +4,7 @@
#include <gtest/gtest.h>
#include <fstream>
#include <iterator> // for back_inserter
#include <map>
#include "../../../src/common/charconv.h"
@@ -691,4 +692,16 @@ TEST(Json, TypeCheck) {
ASSERT_NE(err.find("foo"), std::string::npos);
}
}
TEST(Json, Dump) {
auto str = GetModelStr();
auto jobj = Json::Load(str);
std::string result_s = Json::Dump(jobj);
std::vector<char> result_v = Json::Dump<std::vector<char>>(jobj);
ASSERT_EQ(result_s.size(), result_v.size());
for (std::size_t i = 0; i < result_s.size(); ++i) {
ASSERT_EQ(result_s[i], result_v[i]);
}
}
} // namespace xgboost