2020#include " processor/wetext_processor.h"
2121#include " utils/wetext_string.h"
2222
23+ // Absolute path to the dir with *.fst models and golden data, injected by CMake
24+ // so the test does not depend on the current working directory.
25+ #ifndef WETEXT_TN_DIR
26+ #define WETEXT_TN_DIR " ../tn"
27+ #endif
28+
2329std::vector<std::pair<std::string, std::string>> ParseTestCase (
2430 const std::string& file_path) {
2531 const std::string delimiter = " =>" ;
@@ -52,8 +58,8 @@ class ProcessorTest
5258 std::string spoken;
5359
5460 virtual void SetUp () {
55- std::string tagger_path = " ../tn /zh_tn_tagger.fst" ;
56- std::string verbalizer_path = " ../tn /zh_tn_verbalizer.fst" ;
61+ std::string tagger_path = WETEXT_TN_DIR " /zh_tn_tagger.fst" ;
62+ std::string verbalizer_path = WETEXT_TN_DIR " /zh_tn_verbalizer.fst" ;
5763 processor = new wetext::Processor (tagger_path, verbalizer_path);
5864 written = GetParam ().first ;
5965 spoken = GetParam ().second ;
@@ -67,6 +73,6 @@ TEST_P(ProcessorTest, NormalizeTest) {
6773}
6874
6975std::vector<std::pair<std::string, std::string>> test_cases =
70- ParseTestCase (" ../tn /chinese/test/data/normalizer.txt" );
76+ ParseTestCase (WETEXT_TN_DIR " /chinese/test/data/normalizer.txt" );
7177INSTANTIATE_TEST_SUITE_P (NormalizeTest, ProcessorTest,
7278 testing::ValuesIn (test_cases));
0 commit comments