| 393 | }; |
| 394 | |
| 395 | TEST_F(JiebaPluginIntegrationTest, ConvertFromJsonCases) { |
| 396 | const CasesByConfig cases = LoadCases( |
| 397 | #ifdef BAZEL |
| 398 | runfiles_->Rlocation( |
| 399 | "_main/plugins/jieba/tests/data/jieba_comparison_testcases.json") |
| 400 | #else |
| 401 | std::string(PROJECT_SOURCE_DIR) + |
| 402 | "/plugins/jieba/tests/data/jieba_comparison_testcases.json" |
| 403 | #endif |
| 404 | ); |
| 405 | |
| 406 | for (const auto& entry : cases) { |
| 407 | const std::string& config = entry.first; |
| 408 | const std::string inputFile = InputFile(config); |
| 409 | const std::string outputFile = OutputFile(config); |
| 410 | |
| 411 | { |
| 412 | std::ofstream ofs(inputFile, std::ios::binary); |
| 413 | ASSERT_TRUE(ofs.is_open()); |
| 414 | for (const auto& item : entry.second) { |
| 415 | ofs << item.input << "\n"; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | ASSERT_EQ(0, RunCommandUtf8(BuildCommand(config, inputFile, outputFile))); |
| 420 | |
| 421 | std::ifstream ifs(outputFile, std::ios::binary); |
| 422 | ASSERT_TRUE(ifs.is_open()); |
| 423 | std::string line; |
| 424 | size_t idx = 0; |
| 425 | while (std::getline(ifs, line)) { |
| 426 | if (!line.empty() && line.back() == '\r') { |
| 427 | line.pop_back(); |
| 428 | } |
| 429 | ASSERT_LT(idx, entry.second.size()); |
| 430 | EXPECT_EQ(entry.second[idx].expected, line) |
| 431 | << "config=" << config << " index=" << idx; |
| 432 | idx++; |
| 433 | } |
| 434 | EXPECT_EQ(idx, entry.second.size()) << "config=" << config; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | TEST_F(JiebaPluginIntegrationTest, ConvertWithMergedOcd2JiebaDictionary) { |
| 439 | const std::string inputFile = InputFile("s2twp_jieba_merged"); |
nothing calls this directly
no test coverage detected