diff --git a/unittest/applybox_test.cc b/unittest/applybox_test.cc index 299c9097d..0327cd2f3 100644 --- a/unittest/applybox_test.cc +++ b/unittest/applybox_test.cc @@ -36,7 +36,7 @@ class ApplyBoxTest : public testing::Test { return file::JoinPath(FLAGS_test_tmpdir, name); } - ApplyBoxTest() { src_pix_ = NULL; } + ApplyBoxTest() { src_pix_ = nullptr; } ~ApplyBoxTest() { pixDestroy(&src_pix_); } void SetImage(const char* filename) { @@ -61,7 +61,7 @@ class ApplyBoxTest : public testing::Test { api_.SetVariable("tessedit_resegment_from_line_boxes", "1"); else api_.SetVariable("tessedit_resegment_from_boxes", "1"); - api_.Recognize(NULL); + api_.Recognize(nullptr); char* ocr_text = api_.GetUTF8Text(); EXPECT_STREQ(truth_str, ocr_text); delete[] ocr_text; @@ -69,7 +69,7 @@ class ApplyBoxTest : public testing::Test { // bounding boxes in the ocr output. std::string box_filename = TestDataNameToPath(target_box_file); FILE* box_file = OpenBoxFile(STRING(box_filename.c_str())); - ASSERT_TRUE(box_file != NULL); + ASSERT_TRUE(box_file != nullptr); int height = pixGetHeight(src_pix_); ResultIterator* it = api_.GetIterator(); do { diff --git a/unittest/baseapi_test.cc b/unittest/baseapi_test.cc index ca8b5dcab..41c7de7dd 100644 --- a/unittest/baseapi_test.cc +++ b/unittest/baseapi_test.cc @@ -11,13 +11,13 @@ namespace { using ::testing::ContainsRegex; using ::testing::HasSubstr; -const char* langs[] = {"eng", "vie", "hin", "ara", NULL}; +const char* langs[] = {"eng", "vie", "hin", "ara", nullptr}; const char* image_files[] = {"HelloGoogle.tif", "viet.tif", "raaj.tif", - "arabic.tif", NULL}; + "arabic.tif", nullptr}; const char* gt_text[] = {"Hello Google", "\x74\x69\xe1\xba\xbf\x6e\x67", "\xe0\xa4\xb0\xe0\xa4\xbe\xe0\xa4\x9c", "\xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a", - NULL}; + nullptr}; class FriendlyTessBaseAPI : public tesseract::TessBaseAPI { FRIEND_TEST(TesseractTest, LSTMGeometryTest); @@ -78,11 +78,11 @@ TEST_F(TesseractTest, IteratesParagraphsEvenIfNotDetected) { CHECK(src_pix); api.SetImage(src_pix); Boxa* para_boxes = - api.GetComponentImages(tesseract::RIL_PARA, true, NULL, NULL); - EXPECT_TRUE(para_boxes != NULL); + api.GetComponentImages(tesseract::RIL_PARA, true, nullptr, nullptr); + EXPECT_TRUE(para_boxes != nullptr); Boxa* block_boxes = - api.GetComponentImages(tesseract::RIL_BLOCK, true, NULL, NULL); - EXPECT_TRUE(block_boxes != NULL); + api.GetComponentImages(tesseract::RIL_BLOCK, true, nullptr, nullptr); + EXPECT_TRUE(block_boxes != nullptr); // TODO(eger): Get paragraphs out of this page pre-text. EXPECT_GE(boxaGetCount(para_boxes), boxaGetCount(block_boxes)); boxaDestroy(&block_boxes); @@ -99,7 +99,7 @@ TEST_F(TesseractTest, HOCRWorksWithoutSetInputName) { CHECK(src_pix); api.SetImage(src_pix); char* result = api.GetHOCRText(0); - EXPECT_TRUE(result != NULL); + EXPECT_TRUE(result != nullptr); EXPECT_THAT(result, HasSubstr("Hello")); EXPECT_THAT(result, HasSubstr("
]* " "baseline [-.0-9]+ [-.0-9]+")); @@ -134,7 +134,7 @@ TEST_F(TesseractTest, RickSnyderNotFuckSnyder) { CHECK(src_pix); api.SetImage(src_pix); char* result = api.GetHOCRText(0); - EXPECT_TRUE(result != NULL); + EXPECT_TRUE(result != nullptr); EXPECT_THAT(result, Not(HasSubstr("FUCK"))); delete[] result; pixDestroy(&src_pix); @@ -145,12 +145,12 @@ TEST_F(TesseractTest, AdaptToWordStrTest) { static const char* kTrainingPages[] = { "136.tif", "256.tif", "410.tif", "432.tif", "540.tif", "692.tif", "779.tif", "793.tif", "808.tif", "815.tif", - "12.tif", "12.tif", NULL}; + "12.tif", "12.tif", nullptr}; static const char* kTrainingText[] = { "1 3 6", "2 5 6", "4 1 0", "4 3 2", "5 4 0", "6 9 2", "7 7 9", - "7 9 3", "8 0 8", "8 1 5", "1 2", "1 2", NULL}; - static const char* kTestPages[] = {"324.tif", "433.tif", "12.tif", NULL}; - static const char* kTestText[] = {"324", "433", "12", NULL}; + "7 9 3", "8 0 8", "8 1 5", "1 2", "1 2", nullptr}; + static const char* kTestPages[] = {"324.tif", "433.tif", "12.tif", nullptr}; + static const char* kTestText[] = {"324", "433", "12", nullptr}; tesseract::TessBaseAPI api; string truth_text; string ocr_text; @@ -158,7 +158,7 @@ TEST_F(TesseractTest, AdaptToWordStrTest) { api.SetVariable("matcher_sufficient_examples_for_prototyping", "1"); api.SetVariable("classify_class_pruner_threshold", "220"); // Train on the training text. - for (int i = 0; kTrainingPages[i] != NULL; ++i) { + for (int i = 0; kTrainingPages[i] != nullptr; ++i) { string image_file = TestDataNameToPath(kTrainingPages[i]); Pix* src_pix = pixRead(image_file.c_str()); CHECK(src_pix); @@ -172,7 +172,7 @@ TEST_F(TesseractTest, AdaptToWordStrTest) { // Test the test text. api.SetVariable("tess_bn_matching", "1"); api.SetPageSegMode(tesseract::PSM_SINGLE_WORD); - for (int i = 0; kTestPages[i] != NULL; ++i) { + for (int i = 0; kTestPages[i] != nullptr; ++i) { Pix* src_pix = pixRead(TestDataNameToPath(kTestPages[i]).c_str()); CHECK(src_pix); ocr_text = GetCleanedTextResult(&api, src_pix); @@ -209,7 +209,7 @@ TEST_F(TesseractTest, LSTMGeometryTest) { FriendlyTessBaseAPI api; api.Init(TessdataPath().c_str(), "eng", tesseract::OEM_LSTM_ONLY); api.SetImage(src_pix); - ASSERT_EQ(api.Recognize(NULL), 0); + ASSERT_EQ(api.Recognize(nullptr), 0); const PAGE_RES* page_res = api.GetPageRes(); PAGE_RES_IT page_res_it(const_cast(page_res)); @@ -218,7 +218,7 @@ TEST_F(TesseractTest, LSTMGeometryTest) { CHECK(block); // extract word and character boxes for each word - for (page_res_it.restart_page(); page_res_it.word() != NULL; + for (page_res_it.restart_page(); page_res_it.word() != nullptr; page_res_it.forward()) { WERD_RES* word = page_res_it.word(); CHECK(word); @@ -268,7 +268,7 @@ TEST_F(TesseractTest, InitConfigOnlyTest) { api.reset(new tesseract::TessBaseAPI); timer.Restart(); EXPECT_EQ(0, api->Init(TessdataPath().c_str(), langs[i], - tesseract::OEM_TESSERACT_ONLY, NULL, 0, &vars_vec, + tesseract::OEM_TESSERACT_ONLY, nullptr, 0, &vars_vec, &vars_values, false)); timer.Stop(); LOG(INFO) << "Lang " << langs[i] << " took " << timer.GetInMs() @@ -284,7 +284,7 @@ TEST_F(TesseractTest, InitConfigOnlyTest) { // OEM_DEFAULT mode. TEST(TesseractInstanceTest, TestMultipleTessInstances) { int num_langs = 0; - while (langs[num_langs] != NULL) ++num_langs; + while (langs[num_langs] != nullptr) ++num_langs; const string kTessdataPath = file::JoinPath(FLAGS_test_srcdir, "tessdata"); @@ -294,7 +294,7 @@ TEST(TesseractInstanceTest, TestMultipleTessInstances) { SCOPED_TRACE(absl::StrCat("Single instance test with lang = ", langs[i])); string path = FLAGS_test_srcdir + "/testdata/" + image_files[i]; pix[i] = pixRead(path.c_str()); - QCHECK(pix[i] != NULL) << "Could not read " << path; + QCHECK(pix[i] != nullptr) << "Could not read " << path; tesseract::TessBaseAPI tess; EXPECT_EQ(0, tess.Init(kTessdataPath.c_str(), langs[i])); diff --git a/unittest/baseapi_thread_test.cc b/unittest/baseapi_thread_test.cc index 267daa79b..5ddc26613 100644 --- a/unittest/baseapi_thread_test.cc +++ b/unittest/baseapi_thread_test.cc @@ -37,16 +37,16 @@ using tesseract::TessBaseAPI; namespace { -const char* kTessLangs[] = {"eng", "vie", NULL}; -const char* kTessImages[] = {"HelloGoogle.tif", "viet.tif", NULL}; +const char* kTessLangs[] = {"eng", "vie", nullptr}; +const char* kTessImages[] = {"HelloGoogle.tif", "viet.tif", nullptr}; const char* kTessTruthText[] = {"Hello Google", "\x74\x69\xe1\xba\xbf\x6e\x67", - NULL}; + nullptr}; -const char* kCubeLangs[] = {"hin", "ara", NULL}; -const char* kCubeImages[] = {"raaj.tif", "arabic.tif", NULL}; +const char* kCubeLangs[] = {"hin", "ara", nullptr}; +const char* kCubeImages[] = {"raaj.tif", "arabic.tif", nullptr}; const char* kCubeTruthText[] = { "\xe0\xa4\xb0\xe0\xa4\xbe\xe0\xa4\x9c", - "\xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a", NULL}; + "\xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a", nullptr}; class BaseapiThreadTest : public ::testing::Test { protected: @@ -86,7 +86,7 @@ class BaseapiThreadTest : public ::testing::Test { string path = FLAGS_test_srcdir + "/testdata/" + image_files[i % num_langs_]; Pix* new_pix = pixRead(path.c_str()); - QCHECK(new_pix != NULL) << "Could not read " << path; + QCHECK(new_pix != nullptr) << "Could not read " << path; pix_.push_back(new_pix); } @@ -106,7 +106,7 @@ class BaseapiThreadTest : public ::testing::Test { pool_->StartWorkers(); } - void WaitForPoolWorkers() { pool_.reset(NULL); } + void WaitForPoolWorkers() { pool_.reset(nullptr); } std::unique_ptr pool_; static int pool_size_; @@ -139,7 +139,7 @@ void GetCleanedText(TessBaseAPI* tess, Pix* pix, string* ocr_text) { void VerifyTextResult(TessBaseAPI* tess, Pix* pix, const string& lang, const string& expected_text) { - TessBaseAPI* tess_local = NULL; + TessBaseAPI* tess_local = nullptr; if (tess) { tess_local = tess; } else { @@ -197,7 +197,7 @@ TEST_F(BaseapiThreadTest, TestAll) { const int n = num_langs_ * FLAGS_reps; ResetPool(); for (int i = 0; i < n; ++i) { - pool_->Add(NewCallback(VerifyTextResult, NULL, pix_[i], + pool_->Add(NewCallback(VerifyTextResult, nullptr, pix_[i], langs_[i % num_langs_], gt_text_[i % num_langs_])); } WaitForPoolWorkers(); diff --git a/unittest/denorm_test.cc b/unittest/denorm_test.cc index a941e1b40..861602fbd 100644 --- a/unittest/denorm_test.cc +++ b/unittest/denorm_test.cc @@ -28,7 +28,7 @@ class DENORMTest : public testing::Test { if (local) denorm.LocalNormTransform(src, &normed); else - denorm.NormTransform(NULL, src, &normed); + denorm.NormTransform(nullptr, src, &normed); EXPECT_EQ(result.x, normed.x); EXPECT_EQ(result.y, normed.y); // Now undo @@ -36,7 +36,7 @@ class DENORMTest : public testing::Test { if (local) denorm.LocalDenormTransform(normed, &denormed); else - denorm.DenormTransform(NULL, normed, &denormed); + denorm.DenormTransform(nullptr, normed, &denormed); EXPECT_EQ(src.x, denormed.x); EXPECT_EQ(src.y, denormed.y); } @@ -45,7 +45,7 @@ class DENORMTest : public testing::Test { // Tests a simple baseline-style normalization. TEST_F(DENORMTest, NoRotations) { DENORM denorm; - denorm.SetupNormalization(NULL, NULL, NULL, 1000.0f, 2000.0f, 2.0f, 3.0f, + denorm.SetupNormalization(nullptr, nullptr, nullptr, 1000.0f, 2000.0f, 2.0f, 3.0f, 0.0f, static_cast(kBlnBaselineOffset)); TPOINT pt1(1100, 2000); TPOINT result1(200, kBlnBaselineOffset); @@ -61,7 +61,7 @@ TEST_F(DENORMTest, NoRotations) { TEST_F(DENORMTest, WithRotations) { DENORM denorm; FCOORD rotation90(0.0f, 1.0f); - denorm.SetupNormalization(NULL, &rotation90, NULL, 1000.0f, 2000.0f, 2.0f, + denorm.SetupNormalization(nullptr, &rotation90, nullptr, 1000.0f, 2000.0f, 2.0f, 3.0f, 0.0f, static_cast(kBlnBaselineOffset)); TPOINT pt1(1100, 2000); @@ -77,12 +77,12 @@ TEST_F(DENORMTest, WithRotations) { // Tests a simple baseline-style normalization with a second rotation & scale. TEST_F(DENORMTest, Multiple) { DENORM denorm; - denorm.SetupNormalization(NULL, NULL, NULL, 1000.0f, 2000.0f, 2.0f, 3.0f, + denorm.SetupNormalization(nullptr, nullptr, nullptr, 1000.0f, 2000.0f, 2.0f, 3.0f, 0.0f, static_cast(kBlnBaselineOffset)); DENORM denorm2; FCOORD rotation90(0.0f, 1.0f); - denorm2.SetupNormalization(NULL, &rotation90, &denorm, 128.0f, 128.0f, 0.5f, + denorm2.SetupNormalization(nullptr, &rotation90, &denorm, 128.0f, 128.0f, 0.5f, 0.25f, 0.0f, 0.0f); TPOINT pt1(1050, 2000); TPOINT result1(100, kBlnBaselineOffset); diff --git a/unittest/equationdetect_test.cc b/unittest/equationdetect_test.cc index e03ff9582..e23c4fb1d 100644 --- a/unittest/equationdetect_test.cc +++ b/unittest/equationdetect_test.cc @@ -117,8 +117,8 @@ class EquationFinderTest : public testing::Test { } void TearDown() { - tesseract_.reset(NULL); - equation_det_.reset(NULL); + tesseract_.reset(nullptr); + equation_det_.reset(nullptr); } // Add a BLOCK covering the whole page. @@ -169,7 +169,7 @@ TEST_F(EquationFinderTest, IdentifySpecialText) { // Load Image. string imagefile = file::JoinPath(testdata_dir_, "equ_gt1.tif"); Pix* pix_binary = pixRead(imagefile.c_str()); - CHECK(pix_binary != NULL && pixGetDepth(pix_binary) == 1); + CHECK(pix_binary != nullptr && pixGetDepth(pix_binary) == 1); // Get components. BLOCK_LIST blocks; @@ -364,7 +364,7 @@ TEST_F(EquationFinderTest, ComputeForegroundDensity) { // Create the pix with top half foreground, bottom half background. int width = 1024, height = 768; Pix* pix = pixCreate(width, height, 1); - pixRasterop(pix, 0, 0, width, height / 2, PIX_SET, NULL, 0, 0); + pixRasterop(pix, 0, 0, width, height / 2, PIX_SET, nullptr, 0, 0); TBOX box1(100, 0, 140, 140), box2(100, height / 2 - 20, 140, height / 2 + 20), box3(100, height - 40, 140, height); equation_det_->SetPixBinary(pix); diff --git a/unittest/heap_test.cc b/unittest/heap_test.cc index 130bf1c84..26046d503 100644 --- a/unittest/heap_test.cc +++ b/unittest/heap_test.cc @@ -51,7 +51,7 @@ class HeapTest : public testing::Test { // Indices don't necessarily match for equal keys, so don't test them. if (i + 1 < v->size() && (*v)[i + 1].key == (*v)[i].key) { while (i + 1 < v->size() && (*v)[i + 1].key == (*v)[i].key) { - heap->Pop(NULL); + heap->Pop(nullptr); ++i; EXPECT_FALSE(heap->empty()); EXPECT_EQ((*v)[i].key, heap->PeekTop().key); @@ -61,7 +61,7 @@ class HeapTest : public testing::Test { EXPECT_EQ((*v)[i].data, heap->PeekTop().data); } EXPECT_FALSE(heap->empty()); - EXPECT_TRUE(heap->Pop(NULL)); + EXPECT_TRUE(heap->Pop(nullptr)); } EXPECT_TRUE(heap->empty()); } @@ -95,7 +95,7 @@ TEST_F(HeapTest, MixedTest) { // Sort the vector and remove the first 5 values from both heap and v. v.sort(); for (int i = 0; i < 5; ++i) { - heap.Pop(NULL); + heap.Pop(nullptr); v.remove(0); } // Push the test data onto both the heap and the KDVector. @@ -162,7 +162,7 @@ TEST_F(HeapTest, RevalueTest) { for (int i = 0; i < v.size(); ++i) { EXPECT_EQ(v[i].key, heap.PeekTop().key); EXPECT_FALSE(heap.empty()); - heap.Pop(NULL); + heap.Pop(nullptr); } EXPECT_TRUE(heap.empty()); } @@ -174,7 +174,7 @@ TEST_F(HeapTest, RevalueTest) { static void ConstRefTest(const DoublePtr& ptr1) { DoublePtr ptr2(ptr1); // Compiler error here. EXPECT_EQ(&ptr2, ptr2.OtherEnd()->OtherEnd()); - EXPECT_TRUE(ptr1.OtherEnd() == NULL); + EXPECT_TRUE(ptr1.OtherEnd() == nullptr); } #endif @@ -186,11 +186,11 @@ TEST_F(HeapTest, DoublePtrTest) { // Check that the correct copy constructor is used. DoublePtr ptr3(ptr1); EXPECT_EQ(&ptr3, ptr3.OtherEnd()->OtherEnd()); - EXPECT_TRUE(ptr1.OtherEnd() == NULL); + EXPECT_TRUE(ptr1.OtherEnd() == nullptr); // Check that the correct operator= is used. ptr1 = ptr3; EXPECT_EQ(&ptr1, ptr1.OtherEnd()->OtherEnd()); - EXPECT_TRUE(ptr3.OtherEnd() == NULL); + EXPECT_TRUE(ptr3.OtherEnd() == nullptr); } } // namespace tesseract diff --git a/unittest/imagedata_test.cc b/unittest/imagedata_test.cc index 7abda8e0d..9963e7986 100644 --- a/unittest/imagedata_test.cc +++ b/unittest/imagedata_test.cc @@ -30,14 +30,14 @@ class ImagedataTest : public ::testing::Test { // Make an imagedata and put it in the document. ImageData* imagedata = ImageData::Build("noname", p, "eng", fake_image.data(), - fake_image.size(), (*page_texts)[p].c_str(), NULL); + fake_image.size(), (*page_texts)[p].c_str(), nullptr); EXPECT_EQ(kImageSize, imagedata->MemoryUsed()); write_doc.AddPageToDocument(imagedata); } // Write it to a file. string filename = file::JoinPath( FLAGS_test_tmpdir, absl::StrCat("documentdata", doc_id, ".lstmf")); - EXPECT_TRUE(write_doc.SaveDocument(filename.c_str(), NULL)); + EXPECT_TRUE(write_doc.SaveDocument(filename.c_str(), nullptr)); return filename; } }; @@ -59,13 +59,13 @@ TEST_F(ImagedataTest, CachesProperly) { for (int m = 0; kMemoryAllowances[m] > 0; ++m) { DocumentData read_doc("My document"); EXPECT_TRUE( - read_doc.LoadDocument(filename.c_str(), 0, kMemoryAllowances[m], NULL)); + read_doc.LoadDocument(filename.c_str(), 0, kMemoryAllowances[m], nullptr)); LOG(ERROR) << "Allowance = " << kMemoryAllowances[m]; // Read the pages in a specific order. for (int p = 0; kPageReadOrder[p] >= 0; ++p) { int page = kPageReadOrder[p]; const ImageData* imagedata = read_doc.GetPage(page); - EXPECT_NE(reinterpret_cast(NULL), imagedata); + EXPECT_NE(reinterpret_cast(nullptr), imagedata); // Check that this is the right page. EXPECT_STREQ(page_texts[page].c_str(), imagedata->transcription().string()); diff --git a/unittest/intfeaturemap_test.cc b/unittest/intfeaturemap_test.cc index fd59cbe2b..f9f39aca3 100644 --- a/unittest/intfeaturemap_test.cc +++ b/unittest/intfeaturemap_test.cc @@ -101,7 +101,7 @@ TEST_F(IntFeatureMapTest, Exhaustive) { // test again. map.DeleteMapFeature(0); map.DeleteMapFeature(total_buckets - 1); - map.FinalizeMapping(NULL); + map.FinalizeMapping(nullptr); map.IndexAndSortFeatures(features.get(), total_size, &index_features); // Has no effect on index features. EXPECT_EQ(total_size, index_features.size()); diff --git a/unittest/layout_test.cc b/unittest/layout_test.cc index f63883cc2..4b81b3266 100644 --- a/unittest/layout_test.cc +++ b/unittest/layout_test.cc @@ -17,7 +17,7 @@ using tesseract::PageIteratorLevel; using tesseract::ResultIterator; const char* kStrings8087_054[] = { - "dat", "Dalmatian", "", "DAMAGED DURING", "margarine,", NULL}; + "dat", "Dalmatian", "", "DAMAGED DURING", "margarine,", nullptr}; const PolyBlockType kBlocks8087_054[] = {PT_HEADING_TEXT, PT_FLOWING_TEXT, PT_PULLOUT_IMAGE, PT_CAPTION_TEXT, PT_FLOWING_TEXT}; @@ -32,7 +32,7 @@ class LayoutTest : public testing::Test { return file::JoinPath(FLAGS_test_srcdir, "tessdata"); } - LayoutTest() { src_pix_ = NULL; } + LayoutTest() { src_pix_ = nullptr; } ~LayoutTest() { pixDestroy(&src_pix_); } void SetImage(const char* filename, const char* lang) { @@ -46,7 +46,7 @@ class LayoutTest : public testing::Test { // Tests reading order and block finding (very roughly) by iterating // over the blocks, expecting that they contain the strings in order, // allowing for other blocks in between. - // An empty string should match an image block, and a NULL string + // An empty string should match an image block, and a nullptr string // indicates the end of the array. void VerifyBlockTextOrder(const char* strings[], const PolyBlockType* blocks, ResultIterator* it) { @@ -55,15 +55,15 @@ class LayoutTest : public testing::Test { int block_index = 0; do { char* block_text = it->GetUTF8Text(tesseract::RIL_BLOCK); - if (block_text != NULL && it->BlockType() == blocks[string_index] && - strstr(block_text, strings[string_index]) != NULL) { + if (block_text != nullptr && it->BlockType() == blocks[string_index] && + strstr(block_text, strings[string_index]) != nullptr) { VLOG(1) << StringPrintf("Found string %s in block %d of type %s", strings[string_index], block_index, kPolyBlockNames[blocks[string_index]]); // Found this one. ++string_index; } else if (it->BlockType() == blocks[string_index] && - block_text == NULL && strings[string_index][0] == '\0') { + block_text == nullptr && strings[string_index][0] == '\0') { VLOG(1) << StringPrintf("Found block of type %s at block %d", kPolyBlockNames[blocks[string_index]], block_index); @@ -75,9 +75,9 @@ class LayoutTest : public testing::Test { } delete[] block_text; ++block_index; - if (strings[string_index] == NULL) break; + if (strings[string_index] == nullptr) break; } while (it->Next(tesseract::RIL_BLOCK)); - EXPECT_TRUE(strings[string_index] == NULL); + EXPECT_TRUE(strings[string_index] == nullptr); } // Tests that approximate order of the biggest text blocks is correct. @@ -127,7 +127,7 @@ class LayoutTest : public testing::Test { bottom - top > 200) { const PAGE_RES_IT* pr_it = it->PageResIt(); POLY_BLOCK* pb = pr_it->block()->block->poly_block(); - CHECK(pb != NULL); + CHECK(pb != nullptr); FCOORD skew = pr_it->block()->block->skew(); EXPECT_GT(skew.x(), 0.0f); EXPECT_GT(skew.y(), 0.0f); @@ -165,7 +165,7 @@ class LayoutTest : public testing::Test { TEST_F(LayoutTest, UNLV8087_054) { SetImage("8087_054.3B.tif", "eng"); // Just run recognition. - EXPECT_EQ(api_.Recognize(NULL), 0); + EXPECT_EQ(api_.Recognize(nullptr), 0); // Check iterator position. tesseract::ResultIterator* it = api_.GetIterator(); VerifyBlockTextOrder(kStrings8087_054, kBlocks8087_054, it); @@ -177,7 +177,7 @@ TEST_F(LayoutTest, UNLV8087_054) { TEST_F(LayoutTest, HebrewOrderingAndSkew) { SetImage("GOOGLE:13510798882202548:74:84.sj-79.tif", "eng"); // Just run recognition. - EXPECT_EQ(api_.Recognize(NULL), 0); + EXPECT_EQ(api_.Recognize(nullptr), 0); tesseract::MutableIterator* it = api_.GetMutableIterator(); // In eng mode, block order should not be RTL. VerifyRoughBlockOrder(false, it); @@ -186,7 +186,7 @@ TEST_F(LayoutTest, HebrewOrderingAndSkew) { // Now try again using Hebrew. SetImage("GOOGLE:13510798882202548:74:84.sj-79.tif", "heb"); // Just run recognition. - EXPECT_EQ(api_.Recognize(NULL), 0); + EXPECT_EQ(api_.Recognize(nullptr), 0); it = api_.GetMutableIterator(); // In heb mode, block order should be RTL. VerifyRoughBlockOrder(true, it); diff --git a/unittest/ligature_table_test.cc b/unittest/ligature_table_test.cc index 6f068df09..3e37123e9 100644 --- a/unittest/ligature_table_test.cc +++ b/unittest/ligature_table_test.cc @@ -39,7 +39,7 @@ TEST_F(LigatureTableTest, DoesFillLigatureTables) { TEST_F(LigatureTableTest, DoesAddLigatures) { EXPECT_STREQ(kEngLigatureText, - lig_table_->AddLigatures(kEngNonLigatureText, NULL).c_str()); + lig_table_->AddLigatures(kEngNonLigatureText, nullptr).c_str()); } TEST_F(LigatureTableTest, DoesAddLigaturesWithSupportedFont) { @@ -68,7 +68,7 @@ TEST_F(LigatureTableTest, TestCustomLigatures) { }; for (int i = 0; i < ARRAYSIZE(kTestCases); i += 2) { EXPECT_STREQ(kTestCases[i + 1], - lig_table_->AddLigatures(kTestCases[i], NULL).c_str()); + lig_table_->AddLigatures(kTestCases[i], nullptr).c_str()); EXPECT_STREQ(kTestCases[i], lig_table_->RemoveLigatures(kTestCases[i + 1]).c_str()); EXPECT_STREQ(kTestCases[i], @@ -84,7 +84,7 @@ TEST_F(LigatureTableTest, TestRemovesCustomLigatures) { }; for (int i = 0; i < ARRAYSIZE(kTestCases); i += 3) { EXPECT_STREQ(kTestCases[i + 1], - lig_table_->AddLigatures(kTestCases[i], NULL).c_str()); + lig_table_->AddLigatures(kTestCases[i], nullptr).c_str()); EXPECT_STREQ(kTestCases[i + 2], lig_table_->RemoveCustomLigatures(kTestCases[i + 1]).c_str()); } diff --git a/unittest/mastertrainer_test.cc b/unittest/mastertrainer_test.cc index dffaca0bd..2ce49589e 100644 --- a/unittest/mastertrainer_test.cc +++ b/unittest/mastertrainer_test.cc @@ -149,8 +149,8 @@ class MasterTrainerTest : public testing::Test { } MasterTrainerTest() { - shape_table_ = NULL; - master_trainer_ = NULL; + shape_table_ = nullptr; + master_trainer_ = nullptr; } ~MasterTrainerTest() { delete master_trainer_; @@ -171,12 +171,12 @@ class MasterTrainerTest : public testing::Test { STRING file_prefix; delete master_trainer_; delete shape_table_; - shape_table_ = NULL; + shape_table_ = nullptr; tessoptind = 0; master_trainer_ = LoadTrainingData(argc, argv, false, &shape_table_, &file_prefix); - EXPECT_TRUE(master_trainer_ != NULL); - EXPECT_TRUE(shape_table_ != NULL); + EXPECT_TRUE(master_trainer_ != nullptr); + EXPECT_TRUE(shape_table_ != nullptr); } // EXPECTs that the distance between I and l in Arial is 0 and that the diff --git a/unittest/pagesegmode_test.cc b/unittest/pagesegmode_test.cc index 97fe4f95c..2b91a7b6a 100644 --- a/unittest/pagesegmode_test.cc +++ b/unittest/pagesegmode_test.cc @@ -16,7 +16,7 @@ class PageSegModeTest : public testing::Test { return file::JoinPath(FLAGS_test_srcdir, "tessdata"); } - PageSegModeTest() { src_pix_ = NULL; } + PageSegModeTest() { src_pix_ = nullptr; } ~PageSegModeTest() { pixDestroy(&src_pix_); } void SetImage(const char* filename) { diff --git a/unittest/pango_font_info_test.cc b/unittest/pango_font_info_test.cc index 093ddf94a..a95683fd2 100644 --- a/unittest/pango_font_info_test.cc +++ b/unittest/pango_font_info_test.cc @@ -44,7 +44,7 @@ const char* kBadlyFormedHinWords[] = { "उपयोक्ताो", "नहीें", "कहीअे", "पत्रिाका", "छह्णाीस", #endif // Pango v1.36.2 will render the above words even though they are invalid. - "प्रंात", NULL}; + "प्रंात", nullptr}; class PangoFontInfoTest : public ::testing::Test { protected: @@ -129,7 +129,7 @@ TEST_F(PangoFontInfoTest, CannotRenderUncoveredString) { TEST_F(PangoFontInfoTest, CannotRenderInvalidString) { font_info_.ParseFontDescriptionName("Lohit Hindi 12"); - for (int i = 0; kBadlyFormedHinWords[i] != NULL; ++i) { + for (int i = 0; kBadlyFormedHinWords[i] != nullptr; ++i) { EXPECT_FALSE(font_info_.CanRenderString(kBadlyFormedHinWords[i], strlen(kBadlyFormedHinWords[i]))) << "Can render " << kBadlyFormedHinWords[i]; @@ -230,9 +230,9 @@ TEST_F(FontUtilsTest, DoesFindBestFonts) { } TEST_F(FontUtilsTest, DoesSelectFont) { - const char* kLangText[] = {kArabicText, kEngText, kHinText, kKorText, NULL}; - const char* kLangNames[] = {"Arabic", "English", "Hindi", "Korean", NULL}; - for (int i = 0; kLangText[i] != NULL; ++i) { + const char* kLangText[] = {kArabicText, kEngText, kHinText, kKorText, nullptr}; + const char* kLangNames[] = {"Arabic", "English", "Hindi", "Korean", nullptr}; + for (int i = 0; kLangText[i] != nullptr; ++i) { SCOPED_TRACE(kLangNames[i]); std::vector graphemes; string selected_font; diff --git a/unittest/paragraphs_test.cc b/unittest/paragraphs_test.cc index fc8e08037..2d42e212e 100644 --- a/unittest/paragraphs_test.cc +++ b/unittest/paragraphs_test.cc @@ -39,7 +39,7 @@ void AsciiToRowInfo(const char* text, int row_number, const int kLineSpace = 30; info->text = text; info->has_leaders = - strstr(text, "...") != NULL || strstr(text, ". . .") != NULL; + strstr(text, "...") != nullptr || strstr(text, ". . .") != nullptr; info->has_drop_cap = false; info->pix_ldistance = info->pix_rdistance = 0; info->average_interword_space = kCharWidth; @@ -75,10 +75,10 @@ void AsciiToRowInfo(const char* text, int row_number, info->rword_box = TBOX(row_right - info->pix_rdistance - rword_width, bottom, row_right - info->pix_rdistance, top); tesseract::LeftWordAttributes( - NULL, NULL, info->lword_text, &info->lword_indicates_list_item, + nullptr, nullptr, info->lword_text, &info->lword_indicates_list_item, &info->lword_likely_starts_idea, &info->lword_likely_ends_idea); tesseract::RightWordAttributes( - NULL, NULL, info->rword_text, &info->rword_indicates_list_item, + nullptr, nullptr, info->rword_text, &info->rword_indicates_list_item, &info->rword_likely_starts_idea, &info->rword_likely_ends_idea); } @@ -109,12 +109,12 @@ void EvaluateParagraphDetection(const TextAndModel* correct, int n, if (detected_break && !has_break) incorrect_breaks++; if (has_break) { if (correct[i].model_type == PNONE) { - if (detector_output[i]->model != NULL) { + if (detector_output[i]->model != nullptr) { poorly_matched_models++; } } else { if (correct[i].model.justification() != kUnknown && - (detector_output[i]->model == NULL || + (detector_output[i]->model == nullptr || !correct[i].model.Comparable(*detector_output[i]->model))) { poorly_matched_models++; } diff --git a/unittest/recodebeam_test.cc b/unittest/recodebeam_test.cc index 874938e6d..10b85f53c 100644 --- a/unittest/recodebeam_test.cc +++ b/unittest/recodebeam_test.cc @@ -94,7 +94,7 @@ class RecodeBeamTest : public ::testing::Test { string traineddata_name = lang + ".traineddata"; string traineddata_file = file::JoinPath(FLAGS_test_srcdir, "testdata", traineddata_name); - lstm_dict_.SetupForLoad(NULL); + lstm_dict_.SetupForLoad(nullptr); tesseract::TessdataManager mgr; mgr.Init(traineddata_file.c_str()); lstm_dict_.LoadLSTM(lang.c_str(), &mgr); @@ -110,7 +110,7 @@ class RecodeBeamTest : public ::testing::Test { truth_utf8 += ccutil_.unicharset.id_to_unichar(transcription[i]); } PointerVector words; - ExpectCorrect(output, truth_utf8, NULL, &words); + ExpectCorrect(output, truth_utf8, nullptr, &words); } void ExpectCorrect(const GENERIC_2D_ARRAY& output, const string& truth_utf8, Dict* dict, @@ -245,7 +245,7 @@ class RecodeBeamTest : public ::testing::Test { int t = start_t; GenericVector unichar_ids; EXPECT_TRUE(ccutil_.unicharset.encode_string(utf8_str, true, &unichar_ids, - NULL, NULL)); + nullptr, nullptr)); if (unichar_ids.empty() || utf8_str[0] == '\0') { unichar_ids.clear(); unichar_ids.push_back(unichar_null_char_); @@ -288,7 +288,7 @@ class RecodeBeamTest : public ::testing::Test { const float scores2[], TRand* random) { int width = 0; - while (chars1[width] != NULL) ++width; + while (chars1[width] != nullptr) ++width; int padding = width * RecodedCharID::kMaxCodeLen; int num_codes = recoder_.code_range(); GENERIC_2D_ARRAY outputs(width + padding, num_codes, 0.0f); @@ -404,9 +404,9 @@ TEST_F(RecodeBeamTest, EngDictionary) { GENERIC_2D_ARRAY outputs = GenerateSyntheticOutputs( kGWRTops, kGWRTopScores, kGWR2nds, kGWR2ndScores, nullptr); string default_str; - for (int i = 0; kGWRTops[i] != NULL; ++i) default_str += kGWRTops[i]; + for (int i = 0; kGWRTops[i] != nullptr; ++i) default_str += kGWRTops[i]; PointerVector words; - ExpectCorrect(outputs, default_str, NULL, &words); + ExpectCorrect(outputs, default_str, nullptr, &words); // Now try again with the dictionary. LoadDict("eng_beam"); ExpectCorrect(outputs, "Gets words right.", &lstm_dict_, &words); @@ -418,7 +418,7 @@ TEST_F(RecodeBeamTest, ChiDictionary) { GENERIC_2D_ARRAY outputs = GenerateSyntheticOutputs( kZHTops, kZHTopScores, kZH2nds, kZH2ndScores, nullptr); PointerVector words; - ExpectCorrect(outputs, "实学储啬投学生", NULL, &words); + ExpectCorrect(outputs, "实学储啬投学生", nullptr, &words); // Each is an individual word, with permuter = top choice. EXPECT_EQ(7, words.size()); for (int w = 0; w < words.size(); ++w) { diff --git a/unittest/resultiterator_test.cc b/unittest/resultiterator_test.cc index 5ec8bc2d8..464d70014 100644 --- a/unittest/resultiterator_test.cc +++ b/unittest/resultiterator_test.cc @@ -41,7 +41,7 @@ class ResultIteratorTest : public testing::Test { return file::JoinPath(FLAGS_test_tmpdir, name); } - ResultIteratorTest() { src_pix_ = NULL; } + ResultIteratorTest() { src_pix_ = nullptr; } ~ResultIteratorTest() {} void SetImage(const char* filename) { @@ -102,7 +102,7 @@ class ResultIteratorTest : public testing::Test { if (base::GetFlag(FLAGS_v) >= 1) pixWrite(OutputNameToPath("rebuiltxor.png").c_str(), pix, IFF_PNG); l_int32 pixcount; - pixCountPixels(pix, &pixcount, NULL); + pixCountPixels(pix, &pixcount, nullptr); if (pixcount > max_diff) { string outfile = OutputNameToPath("failedxor.png"); VLOG(1) << "outfile = " << outfile; @@ -231,12 +231,12 @@ class ResultIteratorTest : public testing::Test { // 8087_054.3G.tif. (Dubrovnik), but only if --visual_test is true. TEST_F(ResultIteratorTest, VisualTest) { if (!FLAGS_visual_test) return; - const char* kIms[] = {"8087_054.3G.tif", "8071_093.3B.tif", NULL}; - for (int i = 0; kIms[i] != NULL; ++i) { + const char* kIms[] = {"8087_054.3G.tif", "8071_093.3B.tif", nullptr}; + for (int i = 0; kIms[i] != nullptr; ++i) { SetImage(kIms[i]); // Just run layout analysis. PageIterator* it = api_.AnalyseLayout(); - EXPECT_FALSE(it == NULL); + EXPECT_FALSE(it == nullptr); // Make a scrollview window for the display. int width = pixGetWidth(src_pix_); int height = pixGetHeight(src_pix_); @@ -248,7 +248,7 @@ TEST_F(ResultIteratorTest, VisualTest) { win->Brush(ScrollView::NONE); do { Pta* pts = it->BlockPolygon(); - if (pts != NULL) { + if (pts != nullptr) { win->Pen(color); int num_pts = ptaGetCount(pts); l_float32 x, y; @@ -273,7 +273,7 @@ TEST_F(ResultIteratorTest, EasyTest) { SetImage("phototest.tif"); // Just run layout analysis. PageIterator* p_it = api_.AnalyseLayout(); - EXPECT_FALSE(p_it == NULL); + EXPECT_FALSE(p_it == nullptr); // Check iterator position. EXPECT_TRUE(p_it->IsAtBeginningOf(tesseract::RIL_BLOCK)); // This should be a single block. @@ -349,7 +349,7 @@ TEST_F(ResultIteratorTest, ComplexTest) { SetImage("8087_054.3B.tif"); // Just run layout analysis. PageIterator* it = api_.AnalyseLayout(); - EXPECT_FALSE(it == NULL); + EXPECT_FALSE(it == nullptr); // The images should rebuild almost perfectly. VerifyRebuilds(400, 400, 400, 400, 650, it); delete it; @@ -360,7 +360,7 @@ TEST_F(ResultIteratorTest, GreyTest) { SetImage("8087_054.3G.tif"); // Just run layout analysis. PageIterator* it = api_.AnalyseLayout(); - EXPECT_FALSE(it == NULL); + EXPECT_FALSE(it == nullptr); // The images should rebuild almost perfectly. VerifyRebuilds(600, 600, 600, 600, 600, it); delete it; @@ -382,7 +382,7 @@ TEST_F(ResultIteratorTest, SmallCapDropCapTest) { r_it->WordFontAttributes(&bold, &italic, &underlined, &monospace, &serif, &smallcaps, &pointsize, &font_id); char* word_str = r_it->GetUTF8Text(tesseract::RIL_WORD); - if (word_str != NULL) { + if (word_str != nullptr) { VLOG(1) << StringPrintf("Word %s is %s", word_str, smallcaps ? "Smallcaps" : "Normal"); if (r_it->SymbolIsDropcap()) { @@ -442,12 +442,12 @@ TEST_F(ResultIteratorTest, SubSuperTest) { ++found_subs; } else if (r_it->SymbolIsSuperscript()) { result = r_it->GetUTF8Text(tesseract::RIL_SYMBOL); - if (strchr(kAllowedSupers, result[0]) == NULL) { + if (strchr(kAllowedSupers, result[0]) == nullptr) { char* word = r_it->GetUTF8Text(tesseract::RIL_WORD); LOG(ERROR) << StringPrintf("Char %s in word %s is unexpected super!", result, word); delete [] word; - EXPECT_TRUE(strchr(kAllowedSupers, result[0]) != NULL); + EXPECT_TRUE(strchr(kAllowedSupers, result[0]) != nullptr); } delete [] result; ++found_supers; @@ -547,14 +547,14 @@ TEST_F(ResultIteratorTest, NonNullChoicesTest) { // Iterate over the words. do { char* word_str = r_it->GetUTF8Text(tesseract::RIL_WORD); - if (word_str != NULL) { + if (word_str != nullptr) { VLOG(1) << StringPrintf("Word %s:", word_str); ResultIterator s_it = *r_it; do { tesseract::ChoiceIterator c_it(s_it); do { const char* char_str = c_it.GetUTF8Text(); - if (char_str == NULL) + if (char_str == nullptr) VLOG(1) << "Null char choice"; else VLOG(1) << "Char choice " << char_str; @@ -580,7 +580,7 @@ TEST_F(ResultIteratorTest, NonNullConfidencesTest) { // Iterate over the words. do { char* word_str = r_it->GetUTF8Text(tesseract::RIL_WORD); - if (word_str != NULL) { + if (word_str != nullptr) { EXPECT_FALSE(r_it->Empty(tesseract::RIL_WORD)); EXPECT_FALSE(r_it->Empty(tesseract::RIL_SYMBOL)); ResultIterator s_it = *r_it; diff --git a/unittest/shapetable_test.cc b/unittest/shapetable_test.cc index 64aa0dd98..bfccc68a3 100644 --- a/unittest/shapetable_test.cc +++ b/unittest/shapetable_test.cc @@ -50,7 +50,7 @@ TEST_F(ShapeTest, BasicTest) { // It should still work after file I/O. string filename = TmpNameToPath("shapefile"); FILE* fp = fopen(filename.c_str(), "wb"); - EXPECT_TRUE(fp != NULL); + EXPECT_TRUE(fp != nullptr); EXPECT_TRUE(shape1.Serialize(fp)); fclose(fp); TFile tfp; @@ -138,7 +138,7 @@ TEST_F(ShapeTableTest, FullTest) { EXPECT_EQ(0, st.MasterDestinationIndex(1)); EXPECT_EQ(0, st.MasterDestinationIndex(2)); ShapeTable st2; - st2.AppendMasterShapes(st, NULL); + st2.AppendMasterShapes(st, nullptr); EXPECT_EQ(1, st.NumMasterShapes()); EXPECT_EQ(1, st2.NumShapes()); EXPECT_TRUE(st2.MutableShape(0)->IsEqualUnichars(&shape1)); diff --git a/unittest/stringrenderer_test.cc b/unittest/stringrenderer_test.cc index 87eb6b589..c043f9318 100644 --- a/unittest/stringrenderer_test.cc +++ b/unittest/stringrenderer_test.cc @@ -65,10 +65,10 @@ class StringRendererTest : public ::testing::Test { TEST_F(StringRendererTest, DoesRenderToImage) { renderer_.reset(new StringRenderer("Verdana 10", 600, 600)); - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); EXPECT_GT(renderer_->GetBoxes().size(), 0); DisplayClusterBoxes(pix); pixDestroy(&pix); @@ -91,7 +91,7 @@ TEST_F(StringRendererTest, DoesRenderToImage) { renderer_.reset(new StringRenderer("Arab 10", 600, 600)); EXPECT_EQ(strlen(kArabicText), renderer_->RenderToImage(kArabicText, strlen(kArabicText), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); EXPECT_GT(renderer_->GetBoxes().size(), 0); DisplayClusterBoxes(pix); pixDestroy(&pix); @@ -100,7 +100,7 @@ TEST_F(StringRendererTest, DoesRenderToImage) { renderer_.reset(new StringRenderer("Arab 10", 600, 600)); EXPECT_EQ(strlen(kMixedText), renderer_->RenderToImage(kMixedText, strlen(kMixedText), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); EXPECT_GT(renderer_->GetBoxes().size(), 0); DisplayClusterBoxes(pix); pixDestroy(&pix); @@ -111,10 +111,10 @@ TEST_F(StringRendererTest, DoesRenderToImageWithUnderline) { // Underline all words but NOT intervening spaces. renderer_->set_underline_start_prob(1.0); renderer_->set_underline_continuation_prob(0); - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); EXPECT_GT(renderer_->GetBoxes().size(), 0); DisplayClusterBoxes(pix); pixDestroy(&pix); @@ -125,7 +125,7 @@ TEST_F(StringRendererTest, DoesRenderToImageWithUnderline) { renderer_->set_underline_continuation_prob(1.0); EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); EXPECT_GT(renderer_->GetBoxes().size(), 0); DisplayClusterBoxes(pix); pixDestroy(&pix); @@ -136,7 +136,7 @@ TEST_F(StringRendererTest, DoesRenderToImageWithUnderline) { renderer_->set_underline_continuation_prob(0.5); EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); EXPECT_GT(renderer_->GetBoxes().size(), 0); DisplayClusterBoxes(pix); pixDestroy(&pix); @@ -146,10 +146,10 @@ TEST_F(StringRendererTest, DoesHandleNewlineCharacters) { const char kRawText[] = "\n\n\n A \nB \nC \n\n\n"; const char kStrippedText[] = " A B C "; // text with newline chars removed renderer_.reset(new StringRenderer("Verdana 10", 600, 600)); - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_EQ(strlen(kRawText), renderer_->RenderToImage(kRawText, strlen(kRawText), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); // 3 characters + 4 spaces => 7 boxes EXPECT_EQ(7, renderer_->GetBoxes().size()); // Verify the text content of the boxchars @@ -165,15 +165,15 @@ TEST_F(StringRendererTest, DoesRenderLigatures) { renderer_.reset(new StringRenderer("Arab 12", 600, 250)); const char kArabicLigature[] = "لا"; - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_EQ( strlen(kArabicLigature), renderer_->RenderToImage(kArabicLigature, strlen(kArabicLigature), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); EXPECT_GT(renderer_->GetBoxes().size(), 0); const std::vector& boxes = renderer_->GetBoxes(); EXPECT_EQ(1, boxes.size()); - EXPECT_TRUE(boxes[0]->box() != NULL); + EXPECT_TRUE(boxes[0]->box() != nullptr); EXPECT_STREQ(kArabicLigature, boxes[0]->ch().c_str()); DisplayClusterBoxes(pix); pixDestroy(&pix); @@ -195,7 +195,7 @@ static int FindBoxCharXCoord(const std::vector& boxchars, TEST_F(StringRendererTest, ArabicBoxcharsInLTROrder) { renderer_.reset(new StringRenderer("Arab 10", 600, 600)); - Pix* pix = NULL; + Pix* pix = nullptr; // Arabic letters should be in decreasing x-coordinates const char kArabicWord[] = "\u0644\u0627\u0641\u0643\u0631"; const string kRevWord = "\u0631\u0643\u0641\u0627\u0644"; @@ -220,7 +220,7 @@ TEST_F(StringRendererTest, ArabicBoxcharsInLTROrder) { TEST_F(StringRendererTest, DoesOutputBoxcharsInReadingOrder) { renderer_.reset(new StringRenderer("Arab 10", 600, 600)); - Pix* pix = NULL; + Pix* pix = nullptr; // Arabic letters should be in decreasing x-coordinates const char kArabicWord[] = "والفكر"; renderer_->RenderToImage(kArabicWord, strlen(kArabicWord), &pix); @@ -253,7 +253,7 @@ TEST_F(StringRendererTest, DoesOutputBoxcharsInReadingOrder) { } TEST_F(StringRendererTest, DoesRenderVerticalText) { - Pix* pix = NULL; + Pix* pix = nullptr; renderer_.reset(new StringRenderer("UnBatang 10", 600, 600)); renderer_->set_vertical_text(true); EXPECT_EQ(strlen(kKorText), @@ -267,13 +267,13 @@ TEST_F(StringRendererTest, DoesRenderVerticalText) { // appropriate page numbers. TEST_F(StringRendererTest, DoesKeepAllImageBoxes) { renderer_.reset(new StringRenderer("Verdana 10", 600, 600)); - Pix* pix = NULL; + Pix* pix = nullptr; int num_boxes_per_page = 0; const int kNumTrials = 2; for (int i = 0; i < kNumTrials; ++i) { EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix)); - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); pixDestroy(&pix); EXPECT_GT(renderer_->GetBoxes().size(), 0); if (!num_boxes_per_page) { @@ -290,7 +290,7 @@ TEST_F(StringRendererTest, DoesKeepAllImageBoxes) { TEST_F(StringRendererTest, DoesClearBoxes) { renderer_.reset(new StringRenderer("Verdana 10", 600, 600)); - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix)); pixDestroy(&pix); @@ -307,7 +307,7 @@ TEST_F(StringRendererTest, DoesClearBoxes) { TEST_F(StringRendererTest, DoesLigatureTextForRendering) { renderer_.reset(new StringRenderer("Verdana 10", 600, 600)); renderer_->set_add_ligatures(true); - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_EQ(strlen(kEngNonLigatureText), renderer_->RenderToImage(kEngNonLigatureText, strlen(kEngNonLigatureText), &pix)); @@ -320,7 +320,7 @@ TEST_F(StringRendererTest, DoesLigatureTextForRendering) { TEST_F(StringRendererTest, DoesRetainInputLigatureForRendering) { renderer_.reset(new StringRenderer("Verdana 10", 600, 600)); - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_EQ(strlen(kEngLigatureText), renderer_->RenderToImage(kEngLigatureText, strlen(kEngLigatureText), &pix)); @@ -343,7 +343,7 @@ TEST_F(StringRendererTest, DoesStripUnrenderableWords) { TEST_F(StringRendererTest, DoesRenderWordBoxes) { renderer_.reset(new StringRenderer("Verdana 10", 600, 600)); renderer_->set_output_word_boxes(true); - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix)); pixDestroy(&pix); @@ -358,7 +358,7 @@ TEST_F(StringRendererTest, DoesRenderWordBoxes) { EXPECT_EQ(words[i / 2], boxchars[i]->ch()); if (i < boxchars.size() - 1) { EXPECT_EQ(" ", boxchars[i + 1]->ch()); - EXPECT_TRUE(boxchars[i + 1]->box() == NULL); + EXPECT_TRUE(boxchars[i + 1]->box() == nullptr); } } } @@ -366,7 +366,7 @@ TEST_F(StringRendererTest, DoesRenderWordBoxes) { TEST_F(StringRendererTest, DoesRenderWordBoxesFromMultiLineText) { renderer_.reset(new StringRenderer("Verdana 10", 600, 600)); renderer_->set_output_word_boxes(true); - Pix* pix = NULL; + Pix* pix = nullptr; const char kMultlineText[] = "the quick brown fox\njumps over the lazy dog"; EXPECT_EQ(strlen(kMultlineText), renderer_->RenderToImage(kMultlineText, strlen(kEngText), &pix)); @@ -383,7 +383,7 @@ TEST_F(StringRendererTest, DoesRenderWordBoxesFromMultiLineText) { EXPECT_EQ(words[i / 2], boxchars[i]->ch()); if (i < boxchars.size() - 1) { EXPECT_EQ(" ", boxchars[i + 1]->ch()); - EXPECT_TRUE(boxchars[i + 1]->box() == NULL); + EXPECT_TRUE(boxchars[i + 1]->box() == nullptr); } } } @@ -393,12 +393,12 @@ TEST_F(StringRendererTest, DoesRenderAllFontsToImage) { int offset = 0; string font_used; do { - Pix* pix = NULL; + Pix* pix = nullptr; font_used.clear(); offset += renderer_->RenderAllFontsToImage( 1.0, kEngText + offset, strlen(kEngText + offset), &font_used, &pix); if (offset < strlen(kEngText)) { - EXPECT_TRUE(pix != NULL); + EXPECT_TRUE(pix != nullptr); EXPECT_STRNE("", font_used.c_str()); } if (FLAGS_display) pixDisplay(pix, 0, 0); @@ -410,7 +410,7 @@ TEST_F(StringRendererTest, DoesNotRenderWordJoiner) { renderer_.reset(new StringRenderer("Verdana 10", 500, 200)); const string word = "A- -B C-D A BC"; const string joined_word = StringRenderer::InsertWordJoiners(word); - Pix* pix = NULL; + Pix* pix = nullptr; renderer_->RenderToImage(joined_word.c_str(), joined_word.length(), &pix); pixDestroy(&pix); const std::vector& boxchars = renderer_->GetBoxes(); @@ -427,7 +427,7 @@ TEST_F(StringRendererTest, DoesDropUncoveredChars) { renderer_->set_drop_uncovered_chars(true); const string kWord = "office"; const string kCleanWord = "oice"; - Pix* pix = NULL; + Pix* pix = nullptr; EXPECT_FALSE( renderer_->font().CanRenderString(kWord.c_str(), kWord.length())); EXPECT_FALSE(renderer_->font().CoversUTF8Text(kWord.c_str(), kWord.length())); diff --git a/unittest/tablefind_test.cc b/unittest/tablefind_test.cc index dc4f7d701..a73544c3e 100644 --- a/unittest/tablefind_test.cc +++ b/unittest/tablefind_test.cc @@ -38,9 +38,9 @@ class TestableTableFinder : public tesseract::TableFinder { tesseract::ColPartitionGridSearch gsearch(&fragmented_text_grid_); gsearch.SetUniqueMode(true); gsearch.StartFullSearch(); - ColPartition* part = NULL; + ColPartition* part = nullptr; bool found = false; - while ((part = gsearch.NextFullSearch()) != NULL) { + while ((part = gsearch.NextFullSearch()) != nullptr) { if (part->bounding_box().left() == box.left() && part->bounding_box().bottom() == box.bottom() && part->bounding_box().right() == box.right() && @@ -54,9 +54,9 @@ class TestableTableFinder : public tesseract::TableFinder { tesseract::ColPartitionGridSearch gsearch(&fragmented_text_grid_); gsearch.SetUniqueMode(true); gsearch.StartFullSearch(); - ColPartition* part = NULL; + ColPartition* part = nullptr; int count = 0; - while ((part = gsearch.NextFullSearch()) != NULL) { + while ((part = gsearch.NextFullSearch()) != nullptr) { ++count; } EXPECT_EQ(expected_count, count); @@ -75,9 +75,9 @@ class TableFinderTest : public testing::Test { } void TearDown() { - if (partition_.get() != NULL) partition_->DeleteBoxes(); + if (partition_.get() != nullptr) partition_->DeleteBoxes(); DeletePartitionListBoxes(); - finder_.reset(NULL); + finder_.reset(nullptr); } void MakePartition(int x_min, int y_min, int x_max, int y_max) { @@ -86,7 +86,7 @@ class TableFinderTest : public testing::Test { void MakePartition(int x_min, int y_min, int x_max, int y_max, int first_column, int last_column) { - if (partition_.get() != NULL) partition_->DeleteBoxes(); + if (partition_.get() != nullptr) partition_->DeleteBoxes(); TBOX box; box.set_to_given_coords(x_min, y_min, x_max, y_max); partition_.reset( diff --git a/unittest/textlineprojection_test.cc b/unittest/textlineprojection_test.cc index a0eaa91bb..95b6571e6 100644 --- a/unittest/textlineprojection_test.cc +++ b/unittest/textlineprojection_test.cc @@ -34,12 +34,12 @@ class TextlineProjectionTest : public testing::Test { } TextlineProjectionTest() { - src_pix_ = NULL; - bin_pix_ = NULL; - tesseract_ = NULL; - finder_ = NULL; - denorm_ = NULL; - projection_ = NULL; + src_pix_ = nullptr; + bin_pix_ = nullptr; + tesseract_ = nullptr; + finder_ = nullptr; + denorm_ = nullptr; + projection_ = nullptr; } virtual ~TextlineProjectionTest() { pixDestroy(&src_pix_); @@ -67,14 +67,14 @@ class TextlineProjectionTest : public testing::Test { tesseract::TessdataManager mgr; Tesseract* osd_tess = new Tesseract; OSResults osr; - EXPECT_EQ(osd_tess->init_tesseract(TessdataPath().c_str(), NULL, "osd", - tesseract::OEM_TESSERACT_ONLY, NULL, 0, - NULL, NULL, false, &mgr), + EXPECT_EQ(osd_tess->init_tesseract(TessdataPath().c_str(), nullptr, "osd", + tesseract::OEM_TESSERACT_ONLY, nullptr, 0, + nullptr, nullptr, false, &mgr), 0); tesseract_ = new Tesseract; - EXPECT_EQ(tesseract_->init_tesseract(TessdataPath().c_str(), NULL, "eng", - tesseract::OEM_TESSERACT_ONLY, NULL, 0, - NULL, NULL, false, &mgr), + EXPECT_EQ(tesseract_->init_tesseract(TessdataPath().c_str(), nullptr, "eng", + tesseract::OEM_TESSERACT_ONLY, nullptr, 0, + nullptr, nullptr, false, &mgr), 0); bin_pix_ = api_.GetThresholdedImage(); *tesseract_->mutable_pix_binary() = pixClone(bin_pix_); @@ -88,13 +88,13 @@ class TextlineProjectionTest : public testing::Test { BLOCK_LIST src_blocks; BLOCK_IT block_it(&src_blocks); block_it.add_to_end(block); - Pix* photomask_pix = NULL; + Pix* photomask_pix = nullptr; // The blocks made by the ColumnFinder. Moved to blocks before return. BLOCK_LIST found_blocks; TO_BLOCK_LIST temp_blocks; finder_ = tesseract_->SetupPageSegAndDetectOrientation( tesseract::PSM_AUTO_OSD, &src_blocks, osd_tess, &osr, &temp_blocks, - &photomask_pix, NULL); + &photomask_pix, nullptr); TO_BLOCK_IT to_block_it(&temp_blocks); TO_BLOCK* to_block = to_block_it.data(); denorm_ = finder_->denorm(); @@ -157,7 +157,7 @@ class TextlineProjectionTest : public testing::Test { // line_height is the cap + descender size of the text. void VerifyBoxes(const char* imagefile, int line_height) { SetImage(imagefile); - api_.Recognize(NULL); + api_.Recognize(nullptr); SetupProjection(); MutableIterator* it = api_.GetMutableIterator(); do {