tesseract  5.0.0-alpha-619-ge9db
loadlang_test.cc
Go to the documentation of this file.
1 // File: loadlang_test.cc
3 // Description: Test loading of All languages and Scripts for Tesseract.
4 // Tests for All languages and scripts are Disabled by default.
5 // Force the disabled test to run if required by using the
6 // --gtest_also_run_disabled_tests argument. Author: Shree Devi Kumar
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
18 
19 #include <memory> // std::unique_ptr
20 #include <time.h>
21 #include <tesseract/baseapi.h>
22 #include "include_gunit.h"
23 
24 namespace {
25 
26 class QuickTest : public testing::Test {
27  protected:
28  virtual void SetUp() { start_time_ = time(nullptr); }
29  virtual void TearDown() {
30  const time_t end_time = time(nullptr);
31  EXPECT_TRUE(end_time - start_time_ <= 25)
32  << "The test took too long - "
33  << ::testing::PrintToString(end_time - start_time_);
34  }
35  time_t start_time_;
36 };
37 
38 void LangLoader(const char* lang, const char* tessdatadir) {
39  std::unique_ptr<tesseract::TessBaseAPI> api(new tesseract::TessBaseAPI());
40  ASSERT_FALSE(api->Init(tessdatadir, lang))
41  << "Could not initialize tesseract for $lang.";
42  api->End();
43 }
44 
45 // For all languages
46 
47 class LoadLanguage : public QuickTest,
48  public ::testing::WithParamInterface<const char*> {};
49 
50 TEST_P(LoadLanguage, afr) { LangLoader("afr", GetParam()); }
51 TEST_P(LoadLanguage, amh) { LangLoader("amh", GetParam()); }
52 TEST_P(LoadLanguage, ara) { LangLoader("ara", GetParam()); }
53 TEST_P(LoadLanguage, asm) { LangLoader("asm", GetParam()); }
54 TEST_P(LoadLanguage, aze) { LangLoader("aze", GetParam()); }
55 TEST_P(LoadLanguage, aze_cyrl) { LangLoader("aze_cyrl", GetParam()); }
56 TEST_P(LoadLanguage, bel) { LangLoader("bel", GetParam()); }
57 TEST_P(LoadLanguage, ben) { LangLoader("ben", GetParam()); }
58 TEST_P(LoadLanguage, bod) { LangLoader("bod", GetParam()); }
59 TEST_P(LoadLanguage, bos) { LangLoader("bos", GetParam()); }
60 TEST_P(LoadLanguage, bre) { LangLoader("bre", GetParam()); }
61 TEST_P(LoadLanguage, bul) { LangLoader("bul", GetParam()); }
62 TEST_P(LoadLanguage, cat) { LangLoader("cat", GetParam()); }
63 TEST_P(LoadLanguage, ceb) { LangLoader("ceb", GetParam()); }
64 TEST_P(LoadLanguage, ces) { LangLoader("ces", GetParam()); }
65 TEST_P(LoadLanguage, chi_sim) { LangLoader("chi_sim", GetParam()); }
66 TEST_P(LoadLanguage, chi_sim_vert) { LangLoader("chi_sim_vert", GetParam()); }
67 TEST_P(LoadLanguage, chi_tra) { LangLoader("chi_tra", GetParam()); }
68 TEST_P(LoadLanguage, chi_tra_vert) { LangLoader("chi_tra_vert", GetParam()); }
69 TEST_P(LoadLanguage, chr) { LangLoader("chr", GetParam()); }
70 TEST_P(LoadLanguage, cos) { LangLoader("cos", GetParam()); }
71 TEST_P(LoadLanguage, cym) { LangLoader("cym", GetParam()); }
72 TEST_P(LoadLanguage, dan) { LangLoader("dan", GetParam()); }
73 TEST_P(LoadLanguage, deu) { LangLoader("deu", GetParam()); }
74 TEST_P(LoadLanguage, div) { LangLoader("div", GetParam()); }
75 TEST_P(LoadLanguage, dzo) { LangLoader("dzo", GetParam()); }
76 TEST_P(LoadLanguage, ell) { LangLoader("ell", GetParam()); }
77 TEST_P(LoadLanguage, eng) { LangLoader("eng", GetParam()); }
78 TEST_P(LoadLanguage, enm) { LangLoader("enm", GetParam()); }
79 TEST_P(LoadLanguage, epo) { LangLoader("epo", GetParam()); }
80 TEST_P(LoadLanguage, est) { LangLoader("est", GetParam()); }
81 TEST_P(LoadLanguage, eus) { LangLoader("eus", GetParam()); }
82 TEST_P(LoadLanguage, fao) { LangLoader("fao", GetParam()); }
83 TEST_P(LoadLanguage, fas) { LangLoader("fas", GetParam()); }
84 TEST_P(LoadLanguage, fil) { LangLoader("fil", GetParam()); }
85 TEST_P(LoadLanguage, fin) { LangLoader("fin", GetParam()); }
86 TEST_P(LoadLanguage, fra) { LangLoader("fra", GetParam()); }
87 TEST_P(LoadLanguage, frk) { LangLoader("frk", GetParam()); }
88 TEST_P(LoadLanguage, frm) { LangLoader("frm", GetParam()); }
89 TEST_P(LoadLanguage, fry) { LangLoader("fry", GetParam()); }
90 TEST_P(LoadLanguage, gla) { LangLoader("gla", GetParam()); }
91 TEST_P(LoadLanguage, gle) { LangLoader("gle", GetParam()); }
92 TEST_P(LoadLanguage, glg) { LangLoader("glg", GetParam()); }
93 TEST_P(LoadLanguage, grc) { LangLoader("grc", GetParam()); }
94 TEST_P(LoadLanguage, guj) { LangLoader("guj", GetParam()); }
95 TEST_P(LoadLanguage, hat) { LangLoader("hat", GetParam()); }
96 TEST_P(LoadLanguage, heb) { LangLoader("heb", GetParam()); }
97 TEST_P(LoadLanguage, hin) { LangLoader("hin", GetParam()); }
98 TEST_P(LoadLanguage, hrv) { LangLoader("hrv", GetParam()); }
99 TEST_P(LoadLanguage, hun) { LangLoader("hun", GetParam()); }
100 TEST_P(LoadLanguage, hye) { LangLoader("hye", GetParam()); }
101 TEST_P(LoadLanguage, iku) { LangLoader("iku", GetParam()); }
102 TEST_P(LoadLanguage, ind) { LangLoader("ind", GetParam()); }
103 TEST_P(LoadLanguage, isl) { LangLoader("isl", GetParam()); }
104 TEST_P(LoadLanguage, ita) { LangLoader("ita", GetParam()); }
105 TEST_P(LoadLanguage, ita_old) { LangLoader("ita_old", GetParam()); }
106 TEST_P(LoadLanguage, jav) { LangLoader("jav", GetParam()); }
107 TEST_P(LoadLanguage, jpn) { LangLoader("jpn", GetParam()); }
108 TEST_P(LoadLanguage, jpn_vert) { LangLoader("jpn_vert", GetParam()); }
109 TEST_P(LoadLanguage, kan) { LangLoader("kan", GetParam()); }
110 TEST_P(LoadLanguage, kat) { LangLoader("kat", GetParam()); }
111 TEST_P(LoadLanguage, kat_old) { LangLoader("kat_old", GetParam()); }
112 TEST_P(LoadLanguage, kaz) { LangLoader("kaz", GetParam()); }
113 TEST_P(LoadLanguage, khm) { LangLoader("khm", GetParam()); }
114 TEST_P(LoadLanguage, kir) { LangLoader("kir", GetParam()); }
115 // TEST_P(LoadLanguage, kmr) {LangLoader("kmr" , GetParam());}
116 TEST_P(LoadLanguage, kor) { LangLoader("kor", GetParam()); }
117 TEST_P(LoadLanguage, kor_vert) { LangLoader("kor_vert", GetParam()); }
118 TEST_P(LoadLanguage, lao) { LangLoader("lao", GetParam()); }
119 TEST_P(LoadLanguage, lat) { LangLoader("lat", GetParam()); }
120 TEST_P(LoadLanguage, lav) { LangLoader("lav", GetParam()); }
121 TEST_P(LoadLanguage, lit) { LangLoader("lit", GetParam()); }
122 TEST_P(LoadLanguage, ltz) { LangLoader("ltz", GetParam()); }
123 TEST_P(LoadLanguage, mal) { LangLoader("mal", GetParam()); }
124 TEST_P(LoadLanguage, mar) { LangLoader("mar", GetParam()); }
125 TEST_P(LoadLanguage, mkd) { LangLoader("mkd", GetParam()); }
126 TEST_P(LoadLanguage, mlt) { LangLoader("mlt", GetParam()); }
127 TEST_P(LoadLanguage, mon) { LangLoader("mon", GetParam()); }
128 TEST_P(LoadLanguage, mri) { LangLoader("mri", GetParam()); }
129 TEST_P(LoadLanguage, msa) { LangLoader("msa", GetParam()); }
130 TEST_P(LoadLanguage, mya) { LangLoader("mya", GetParam()); }
131 TEST_P(LoadLanguage, nep) { LangLoader("nep", GetParam()); }
132 TEST_P(LoadLanguage, nld) { LangLoader("nld", GetParam()); }
133 TEST_P(LoadLanguage, nor) { LangLoader("nor", GetParam()); }
134 TEST_P(LoadLanguage, oci) { LangLoader("oci", GetParam()); }
135 TEST_P(LoadLanguage, ori) { LangLoader("ori", GetParam()); }
136 TEST_P(LoadLanguage, osd) { LangLoader("osd", GetParam()); }
137 TEST_P(LoadLanguage, pan) { LangLoader("pan", GetParam()); }
138 TEST_P(LoadLanguage, pol) { LangLoader("pol", GetParam()); }
139 TEST_P(LoadLanguage, por) { LangLoader("por", GetParam()); }
140 TEST_P(LoadLanguage, pus) { LangLoader("pus", GetParam()); }
141 TEST_P(LoadLanguage, que) { LangLoader("que", GetParam()); }
142 TEST_P(LoadLanguage, ron) { LangLoader("ron", GetParam()); }
143 TEST_P(LoadLanguage, rus) { LangLoader("rus", GetParam()); }
144 TEST_P(LoadLanguage, san) { LangLoader("san", GetParam()); }
145 TEST_P(LoadLanguage, sin) { LangLoader("sin", GetParam()); }
146 TEST_P(LoadLanguage, slk) { LangLoader("slk", GetParam()); }
147 TEST_P(LoadLanguage, slv) { LangLoader("slv", GetParam()); }
148 TEST_P(LoadLanguage, snd) { LangLoader("snd", GetParam()); }
149 TEST_P(LoadLanguage, spa) { LangLoader("spa", GetParam()); }
150 TEST_P(LoadLanguage, spa_old) { LangLoader("spa_old", GetParam()); }
151 TEST_P(LoadLanguage, sqi) { LangLoader("sqi", GetParam()); }
152 TEST_P(LoadLanguage, srp) { LangLoader("srp", GetParam()); }
153 TEST_P(LoadLanguage, srp_latn) { LangLoader("srp_latn", GetParam()); }
154 TEST_P(LoadLanguage, sun) { LangLoader("sun", GetParam()); }
155 TEST_P(LoadLanguage, swa) { LangLoader("swa", GetParam()); }
156 TEST_P(LoadLanguage, swe) { LangLoader("swe", GetParam()); }
157 TEST_P(LoadLanguage, syr) { LangLoader("syr", GetParam()); }
158 TEST_P(LoadLanguage, tam) { LangLoader("tam", GetParam()); }
159 TEST_P(LoadLanguage, tat) { LangLoader("tat", GetParam()); }
160 TEST_P(LoadLanguage, tel) { LangLoader("tel", GetParam()); }
161 TEST_P(LoadLanguage, tgk) { LangLoader("tgk", GetParam()); }
162 TEST_P(LoadLanguage, tha) { LangLoader("tha", GetParam()); }
163 TEST_P(LoadLanguage, tir) { LangLoader("tir", GetParam()); }
164 TEST_P(LoadLanguage, ton) { LangLoader("ton", GetParam()); }
165 TEST_P(LoadLanguage, tur) { LangLoader("tur", GetParam()); }
166 TEST_P(LoadLanguage, uig) { LangLoader("uig", GetParam()); }
167 TEST_P(LoadLanguage, ukr) { LangLoader("ukr", GetParam()); }
168 TEST_P(LoadLanguage, urd) { LangLoader("urd", GetParam()); }
169 TEST_P(LoadLanguage, uzb) { LangLoader("uzb", GetParam()); }
170 TEST_P(LoadLanguage, uzb_cyrl) { LangLoader("uzb_cyrl", GetParam()); }
171 TEST_P(LoadLanguage, vie) { LangLoader("vie", GetParam()); }
172 TEST_P(LoadLanguage, yid) { LangLoader("yid", GetParam()); }
173 TEST_P(LoadLanguage, yor) { LangLoader("yor", GetParam()); }
174 
175 INSTANTIATE_TEST_CASE_P(DISABLED_Tessdata_fast, LoadLanguage,
176  ::testing::Values(TESSDATA_DIR "_fast"));
177 INSTANTIATE_TEST_CASE_P(DISABLED_Tessdata_best, LoadLanguage,
178  ::testing::Values(TESSDATA_DIR "_best"));
179 INSTANTIATE_TEST_CASE_P(DISABLED_Tessdata, LoadLanguage,
180  ::testing::Values(TESSDATA_DIR));
181 
182 // For all scripts
183 
184 class LoadScript : public QuickTest,
185  public ::testing::WithParamInterface<const char*> {};
186 
187 TEST_P(LoadScript, Arabic) { LangLoader("script/Arabic", GetParam()); }
188 TEST_P(LoadScript, Armenian) { LangLoader("script/Armenian", GetParam()); }
189 TEST_P(LoadScript, Bengali) { LangLoader("script/Bengali", GetParam()); }
190 TEST_P(LoadScript, Canadian_Aboriginal) {
191  LangLoader("script/Canadian_Aboriginal", GetParam());
192 }
193 TEST_P(LoadScript, Cherokee) { LangLoader("script/Cherokee", GetParam()); }
194 TEST_P(LoadScript, Cyrillic) { LangLoader("script/Cyrillic", GetParam()); }
195 TEST_P(LoadScript, Devanagari) { LangLoader("script/Devanagari", GetParam()); }
196 TEST_P(LoadScript, Ethiopic) { LangLoader("script/Ethiopic", GetParam()); }
197 TEST_P(LoadScript, Fraktur) { LangLoader("script/Fraktur", GetParam()); }
198 TEST_P(LoadScript, Georgian) { LangLoader("script/Georgian", GetParam()); }
199 TEST_P(LoadScript, Greek) { LangLoader("script/Greek", GetParam()); }
200 TEST_P(LoadScript, Gujarati) { LangLoader("script/Gujarati", GetParam()); }
201 TEST_P(LoadScript, Gurmukhi) { LangLoader("script/Gurmukhi", GetParam()); }
202 TEST_P(LoadScript, HanS) { LangLoader("script/HanS", GetParam()); }
203 TEST_P(LoadScript, HanS_vert) { LangLoader("script/HanS_vert", GetParam()); }
204 TEST_P(LoadScript, HanT) { LangLoader("script/HanT", GetParam()); }
205 TEST_P(LoadScript, HanT_vert) { LangLoader("script/HanT_vert", GetParam()); }
206 TEST_P(LoadScript, Hangul) { LangLoader("script/Hangul", GetParam()); }
207 TEST_P(LoadScript, Hangul_vert) {
208  LangLoader("script/Hangul_vert", GetParam());
209 }
210 TEST_P(LoadScript, Hebrew) { LangLoader("script/Hebrew", GetParam()); }
211 TEST_P(LoadScript, Japanese) { LangLoader("script/Japanese", GetParam()); }
212 TEST_P(LoadScript, Japanese_vert) {
213  LangLoader("script/Japanese_vert", GetParam());
214 }
215 TEST_P(LoadScript, Kannada) { LangLoader("script/Kannada", GetParam()); }
216 TEST_P(LoadScript, Khmer) { LangLoader("script/Khmer", GetParam()); }
217 TEST_P(LoadScript, Lao) { LangLoader("script/Lao", GetParam()); }
218 TEST_P(LoadScript, Latin) { LangLoader("script/Latin", GetParam()); }
219 TEST_P(LoadScript, Malayalam) { LangLoader("script/Malayalam", GetParam()); }
220 TEST_P(LoadScript, Myanmar) { LangLoader("script/Myanmar", GetParam()); }
221 TEST_P(LoadScript, Oriya) { LangLoader("script/Oriya", GetParam()); }
222 TEST_P(LoadScript, Sinhala) { LangLoader("script/Sinhala", GetParam()); }
223 TEST_P(LoadScript, Syriac) { LangLoader("script/Syriac", GetParam()); }
224 TEST_P(LoadScript, Tamil) { LangLoader("script/Tamil", GetParam()); }
225 TEST_P(LoadScript, Telugu) { LangLoader("script/Telugu", GetParam()); }
226 TEST_P(LoadScript, Thaana) { LangLoader("script/Thaana", GetParam()); }
227 TEST_P(LoadScript, Thai) { LangLoader("script/Thai", GetParam()); }
228 TEST_P(LoadScript, Tibetan) { LangLoader("script/Tibetan", GetParam()); }
229 TEST_P(LoadScript, Vietnamese) { LangLoader("script/Vietnamese", GetParam()); }
230 
231 INSTANTIATE_TEST_CASE_P(DISABLED_Tessdata_fast, LoadScript,
232  ::testing::Values(TESSDATA_DIR "_fast"));
233 INSTANTIATE_TEST_CASE_P(DISABLED_Tessdata_best, LoadScript,
234  ::testing::Values(TESSDATA_DIR "_best"));
235 INSTANTIATE_TEST_CASE_P(DISABLED_Tessdata, LoadScript,
236  ::testing::Values(TESSDATA_DIR));
237 
238 class LoadLang : public QuickTest {};
239 
240 // Test Load of English here, as the parameterized tests are disabled by
241 // default.
242 TEST_F(LoadLang, engFast) { LangLoader("eng", TESSDATA_DIR "_fast"); }
243 TEST_F(LoadLang, engBest) { LangLoader("eng", TESSDATA_DIR "_best"); }
244 TEST_F(LoadLang, engBestInt) { LangLoader("eng", TESSDATA_DIR); }
245 
246 // Use class LoadLang for languages which are NOT there in all three repos
247 TEST_F(LoadLang, kmrFast) { LangLoader("kmr", TESSDATA_DIR "_fast"); }
248 TEST_F(LoadLang, kmrBest) { LangLoader("kmr", TESSDATA_DIR "_best"); }
249 // TEST_F(LoadLang, kmrBestInt) {LangLoader("kmr" , TESSDATA_DIR);}
250 
251 } // namespace
include_gunit.h
tesseract::TEST_F
TEST_F(EquationFinderTest, IdentifySpecialText)
Definition: equationdetect_test.cc:181
baseapi.h
tesseract::TessBaseAPI
Definition: baseapi.h:98