MCPcopy Create free account
hub / github.com/apache/arrow / RunCommand

Function RunCommand

cpp/src/arrow/integration/json_integration_test.cc:223–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223Status RunCommand(const std::string& json_path, const std::string& arrow_path,
224 const std::string& command) {
225 // Make sure the required extension types are registered, as they will be
226 // referenced in test data.
227 ExtensionTypeGuard ext_guard({uuid(), dict_extension_type()});
228
229 if (json_path == "") {
230 return Status::Invalid("Must specify json file name");
231 }
232
233 if (arrow_path == "") {
234 return Status::Invalid("Must specify arrow file name");
235 }
236
237 auto file_exists = [](const char* path) { return std::ifstream(path).good(); };
238
239 if (command == "ARROW_TO_JSON") {
240 if (!file_exists(arrow_path.c_str())) {
241 return Status::Invalid("Input file does not exist");
242 }
243
244 return ConvertArrowToJson(arrow_path, json_path);
245 } else if (command == "JSON_TO_ARROW") {
246 if (!file_exists(json_path.c_str())) {
247 return Status::Invalid("Input file does not exist");
248 }
249
250 return ConvertJsonToArrow(json_path, arrow_path);
251 } else if (command == "VALIDATE") {
252 if (!file_exists(json_path.c_str())) {
253 return Status::Invalid("JSON file does not exist");
254 }
255
256 if (!file_exists(arrow_path.c_str())) {
257 return Status::Invalid("Arrow file does not exist");
258 }
259
260 return ValidateArrowVsJson(arrow_path, json_path);
261 } else {
262 return Status::Invalid("Unknown command: ", command);
263 }
264}
265
266class TestJSONIntegration : public ::testing::Test {
267 public:

Callers 2

TEST_FFunction · 0.85
mainFunction · 0.85

Calls 6

dict_extension_typeFunction · 0.85
ConvertArrowToJsonFunction · 0.85
ConvertJsonToArrowFunction · 0.85
ValidateArrowVsJsonFunction · 0.85
uuidFunction · 0.50
InvalidFunction · 0.50

Tested by

no test coverage detected