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

Function RunCommand

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

Source from the content-addressed store, hash-verified

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

Callers 2

TEST_FFunction · 0.85
mainFunction · 0.85

Calls 8

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