MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / TEST_F

Function TEST_F

plugins/jieba/tests/JiebaPluginIntegrationTest.cpp:395–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393};
394
395TEST_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
438TEST_F(JiebaPluginIntegrationTest, ConvertWithMergedOcd2JiebaDictionary) {
439 const std::string inputFile = InputFile("s2twp_jieba_merged");

Callers

nothing calls this directly

Calls 8

LoadCasesFunction · 0.85
CopyRegularFilesFunction · 0.85
RunProcessWideFunction · 0.85
WideFromUtf8Function · 0.70
is_openMethod · 0.45
emptyMethod · 0.45
pop_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected