@@ -11,13 +11,13 @@ namespace {
11
11
using ::testing::ContainsRegex;
12
12
using ::testing::HasSubstr;
13
13
14
- const char * langs[] = {" eng" , " vie" , " hin" , " ara" , NULL };
14
+ const char * langs[] = {" eng" , " vie" , " hin" , " ara" , nullptr };
15
15
const char * image_files[] = {" HelloGoogle.tif" , " viet.tif" , " raaj.tif" ,
16
- " arabic.tif" , NULL };
16
+ " arabic.tif" , nullptr };
17
17
const char * gt_text[] = {" Hello Google" , " \x74\x69\xe1\xba\xbf\x6e\x67 " ,
18
18
" \xe0\xa4\xb0\xe0\xa4\xbe\xe0\xa4\x9c " ,
19
19
" \xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a " ,
20
- NULL };
20
+ nullptr };
21
21
22
22
class FriendlyTessBaseAPI : public tesseract ::TessBaseAPI {
23
23
FRIEND_TEST (TesseractTest, LSTMGeometryTest);
@@ -78,11 +78,11 @@ TEST_F(TesseractTest, IteratesParagraphsEvenIfNotDetected) {
78
78
CHECK (src_pix);
79
79
api.SetImage (src_pix);
80
80
Boxa* para_boxes =
81
- api.GetComponentImages (tesseract::RIL_PARA, true , NULL , NULL );
82
- EXPECT_TRUE (para_boxes != NULL );
81
+ api.GetComponentImages (tesseract::RIL_PARA, true , nullptr , nullptr );
82
+ EXPECT_TRUE (para_boxes != nullptr );
83
83
Boxa* block_boxes =
84
- api.GetComponentImages (tesseract::RIL_BLOCK, true , NULL , NULL );
85
- EXPECT_TRUE (block_boxes != NULL );
84
+ api.GetComponentImages (tesseract::RIL_BLOCK, true , nullptr , nullptr );
85
+ EXPECT_TRUE (block_boxes != nullptr );
86
86
// TODO(eger): Get paragraphs out of this page pre-text.
87
87
EXPECT_GE (boxaGetCount (para_boxes), boxaGetCount (block_boxes));
88
88
boxaDestroy (&block_boxes);
@@ -99,7 +99,7 @@ TEST_F(TesseractTest, HOCRWorksWithoutSetInputName) {
99
99
CHECK (src_pix);
100
100
api.SetImage (src_pix);
101
101
char * result = api.GetHOCRText (0 );
102
- EXPECT_TRUE (result != NULL );
102
+ EXPECT_TRUE (result != nullptr );
103
103
EXPECT_THAT (result, HasSubstr (" Hello" ));
104
104
EXPECT_THAT (result, HasSubstr (" <div class='ocr_page'" ));
105
105
delete[] result;
@@ -115,7 +115,7 @@ TEST_F(TesseractTest, HOCRContainsBaseline) {
115
115
api.SetInputName (" HelloGoogle.tif" );
116
116
api.SetImage (src_pix);
117
117
char * result = api.GetHOCRText (0 );
118
- EXPECT_TRUE (result != NULL );
118
+ EXPECT_TRUE (result != nullptr );
119
119
EXPECT_THAT (result, HasSubstr (" Hello" ));
120
120
EXPECT_THAT (result, ContainsRegex (" <span class='ocr_line'[^>]* "
121
121
" baseline [-.0-9]+ [-.0-9]+" ));
@@ -134,7 +134,7 @@ TEST_F(TesseractTest, RickSnyderNotFuckSnyder) {
134
134
CHECK (src_pix);
135
135
api.SetImage (src_pix);
136
136
char * result = api.GetHOCRText (0 );
137
- EXPECT_TRUE (result != NULL );
137
+ EXPECT_TRUE (result != nullptr );
138
138
EXPECT_THAT (result, Not (HasSubstr (" FUCK" )));
139
139
delete[] result;
140
140
pixDestroy (&src_pix);
@@ -145,20 +145,20 @@ TEST_F(TesseractTest, AdaptToWordStrTest) {
145
145
static const char * kTrainingPages [] = {
146
146
" 136.tif" , " 256.tif" , " 410.tif" , " 432.tif" , " 540.tif" ,
147
147
" 692.tif" , " 779.tif" , " 793.tif" , " 808.tif" , " 815.tif" ,
148
- " 12.tif" , " 12.tif" , NULL };
148
+ " 12.tif" , " 12.tif" , nullptr };
149
149
static const char * kTrainingText [] = {
150
150
" 1 3 6" , " 2 5 6" , " 4 1 0" , " 4 3 2" , " 5 4 0" , " 6 9 2" , " 7 7 9" ,
151
- " 7 9 3" , " 8 0 8" , " 8 1 5" , " 1 2" , " 1 2" , NULL };
152
- static const char * kTestPages [] = {" 324.tif" , " 433.tif" , " 12.tif" , NULL };
153
- static const char * kTestText [] = {" 324" , " 433" , " 12" , NULL };
151
+ " 7 9 3" , " 8 0 8" , " 8 1 5" , " 1 2" , " 1 2" , nullptr };
152
+ static const char * kTestPages [] = {" 324.tif" , " 433.tif" , " 12.tif" , nullptr };
153
+ static const char * kTestText [] = {" 324" , " 433" , " 12" , nullptr };
154
154
tesseract::TessBaseAPI api;
155
155
string truth_text;
156
156
string ocr_text;
157
157
api.Init (TessdataPath ().c_str (), " eng" , tesseract::OEM_TESSERACT_ONLY);
158
158
api.SetVariable (" matcher_sufficient_examples_for_prototyping" , " 1" );
159
159
api.SetVariable (" classify_class_pruner_threshold" , " 220" );
160
160
// Train on the training text.
161
- for (int i = 0 ; kTrainingPages [i] != NULL ; ++i) {
161
+ for (int i = 0 ; kTrainingPages [i] != nullptr ; ++i) {
162
162
string image_file = TestDataNameToPath (kTrainingPages [i]);
163
163
Pix* src_pix = pixRead (image_file.c_str ());
164
164
CHECK (src_pix);
@@ -172,7 +172,7 @@ TEST_F(TesseractTest, AdaptToWordStrTest) {
172
172
// Test the test text.
173
173
api.SetVariable (" tess_bn_matching" , " 1" );
174
174
api.SetPageSegMode (tesseract::PSM_SINGLE_WORD);
175
- for (int i = 0 ; kTestPages [i] != NULL ; ++i) {
175
+ for (int i = 0 ; kTestPages [i] != nullptr ; ++i) {
176
176
Pix* src_pix = pixRead (TestDataNameToPath (kTestPages [i]).c_str ());
177
177
CHECK (src_pix);
178
178
ocr_text = GetCleanedTextResult (&api, src_pix);
@@ -209,7 +209,7 @@ TEST_F(TesseractTest, LSTMGeometryTest) {
209
209
FriendlyTessBaseAPI api;
210
210
api.Init (TessdataPath ().c_str (), " eng" , tesseract::OEM_LSTM_ONLY);
211
211
api.SetImage (src_pix);
212
- ASSERT_EQ (api.Recognize (NULL ), 0 );
212
+ ASSERT_EQ (api.Recognize (nullptr ), 0 );
213
213
214
214
const PAGE_RES* page_res = api.GetPageRes ();
215
215
PAGE_RES_IT page_res_it (const_cast <PAGE_RES*>(page_res));
@@ -218,7 +218,7 @@ TEST_F(TesseractTest, LSTMGeometryTest) {
218
218
CHECK (block);
219
219
220
220
// extract word and character boxes for each word
221
- for (page_res_it.restart_page (); page_res_it.word () != NULL ;
221
+ for (page_res_it.restart_page (); page_res_it.word () != nullptr ;
222
222
page_res_it.forward ()) {
223
223
WERD_RES* word = page_res_it.word ();
224
224
CHECK (word);
@@ -268,7 +268,7 @@ TEST_F(TesseractTest, InitConfigOnlyTest) {
268
268
api.reset (new tesseract::TessBaseAPI);
269
269
timer.Restart ();
270
270
EXPECT_EQ (0 , api->Init (TessdataPath ().c_str (), langs[i],
271
- tesseract::OEM_TESSERACT_ONLY, NULL , 0 , &vars_vec,
271
+ tesseract::OEM_TESSERACT_ONLY, nullptr , 0 , &vars_vec,
272
272
&vars_values, false ));
273
273
timer.Stop ();
274
274
LOG (INFO) << " Lang " << langs[i] << " took " << timer.GetInMs ()
@@ -284,7 +284,7 @@ TEST_F(TesseractTest, InitConfigOnlyTest) {
284
284
// OEM_DEFAULT mode.
285
285
TEST (TesseractInstanceTest, TestMultipleTessInstances) {
286
286
int num_langs = 0 ;
287
- while (langs[num_langs] != NULL ) ++num_langs;
287
+ while (langs[num_langs] != nullptr ) ++num_langs;
288
288
289
289
const string kTessdataPath = file::JoinPath (FLAGS_test_srcdir, " tessdata" );
290
290
@@ -294,7 +294,7 @@ TEST(TesseractInstanceTest, TestMultipleTessInstances) {
294
294
SCOPED_TRACE (absl::StrCat (" Single instance test with lang = " , langs[i]));
295
295
string path = FLAGS_test_srcdir + " /testdata/" + image_files[i];
296
296
pix[i] = pixRead (path.c_str ());
297
- QCHECK (pix[i] != NULL ) << " Could not read " << path;
297
+ QCHECK (pix[i] != nullptr ) << " Could not read " << path;
298
298
299
299
tesseract::TessBaseAPI tess;
300
300
EXPECT_EQ (0 , tess.Init (kTessdataPath .c_str (), langs[i]));
0 commit comments