| 343 | } |
| 344 | |
| 345 | static std::vector<std::string> get_all_jsons(const std::string& dirname) { |
| 346 | DIR* dir = opendir(dirname.c_str()); |
| 347 | std::vector<std::string> jsons; |
| 348 | EXPECT_TRUE(dir != nullptr) << "Error open directory: " + dirname; |
| 349 | if (nullptr == dir) return jsons; |
| 350 | struct dirent* ent = nullptr; |
| 351 | while (nullptr != (ent = readdir(dir))) { |
| 352 | struct stat st; |
| 353 | std::string filename = dirname + ent->d_name; |
| 354 | int ret = lstat(filename.c_str(), &st); |
| 355 | if (ret == -1) { |
| 356 | goto return_label; |
| 357 | } |
| 358 | if (S_ISDIR(st.st_mode)) { |
| 359 | if (ent->d_name[0] == '.') { |
| 360 | continue; |
| 361 | } |
| 362 | auto sub_jsons = get_all_jsons(filename + '/'); |
| 363 | jsons.insert(jsons.end(), sub_jsons.begin(), sub_jsons.end()); |
| 364 | } else { |
| 365 | auto const pos = filename.find_last_of('.'); |
| 366 | const auto extension = filename.substr(pos + 1); |
| 367 | if (extension == "json") { |
| 368 | jsons.push_back(get_json(filename)); |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | return_label: |
| 374 | closedir(dir); |
| 375 | return jsons; |
| 376 | } |
| 377 | |
| 378 | TYPED_TEST(DocumentTest, ParseFile) { |
| 379 | using Document = TypeParam; |
no test coverage detected