@@ -135,30 +135,38 @@ TEST_F(DictionaryRunfilesTest, TWPhrasesReverseMapping) {
135135 return map;
136136 };
137137
138- LexiconPtr twPhrases = loadLexicon (twPhrasesFile);
139- LexiconPtr twPhrasesRev = loadLexicon (twPhrasesRevFile);
140- ASSERT_NE (twPhrases, nullptr );
141- ASSERT_NE (twPhrasesRev, nullptr );
142-
143- auto twMap = buildMap (twPhrases);
144- auto twRevMap = buildMap (twPhrasesRev);
145-
146- for (const auto & entry : twMap) {
147- const std::string& key = entry.first ;
148- for (const auto & value : entry.second ) {
149- auto it = twRevMap.find (value);
150- EXPECT_TRUE (it != twRevMap.end () && it->second .count (key) > 0 )
151- << " Missing reverse mapping: " << key << " -> " << value;
138+ try {
139+ LexiconPtr twPhrases = loadLexicon (twPhrasesFile);
140+ LexiconPtr twPhrasesRev = loadLexicon (twPhrasesRevFile);
141+ ASSERT_NE (twPhrases, nullptr );
142+ ASSERT_NE (twPhrasesRev, nullptr );
143+
144+ auto twMap = buildMap (twPhrases);
145+ auto twRevMap = buildMap (twPhrasesRev);
146+
147+ for (const auto & entry : twMap) {
148+ const std::string& key = entry.first ;
149+ for (const auto & value : entry.second ) {
150+ auto it = twRevMap.find (value);
151+ EXPECT_TRUE (it != twRevMap.end () && it->second .count (key) > 0 )
152+ << " Missing reverse mapping: " << key << " -> " << value;
153+ }
152154 }
153- }
154155
155- for (const auto & entry : twRevMap) {
156- const std::string& key = entry.first ;
157- for (const auto & value : entry.second ) {
158- auto it = twMap.find (value);
159- EXPECT_TRUE (it != twMap.end () && it->second .count (key) > 0 )
160- << " Missing reverse mapping: " << key << " -> " << value;
156+ for (const auto & entry : twRevMap) {
157+ const std::string& key = entry.first ;
158+ for (const auto & value : entry.second ) {
159+ auto it = twMap.find (value);
160+ EXPECT_TRUE (it != twMap.end () && it->second .count (key) > 0 )
161+ << " Missing reverse mapping: " << key << " -> " << value;
162+ }
161163 }
164+ } catch (const Exception& ex) {
165+ FAIL () << " Exception: " << ex.what ();
166+ } catch (const std::exception& ex) {
167+ FAIL () << " std::exception: " << ex.what ();
168+ } catch (...) {
169+ FAIL () << " Unknown exception thrown during reverse mapping check." ;
162170 }
163171}
164172
0 commit comments