From cb80eb69635214780090af35baa4c5a7c81a4f3e Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 22 Mar 2021 08:26:05 +0100 Subject: [PATCH] Modernize code (clang-tidy -checks='-*,modernize-use-override') Signed-off-by: Stefan Weil --- unittest/apiexample_test.cc | 4 ++-- unittest/applybox_test.cc | 2 +- unittest/colpartition_test.cc | 4 ++-- unittest/dawg_test.cc | 2 +- unittest/denorm_test.cc | 4 ++-- unittest/equationdetect_test.cc | 4 ++-- unittest/heap_test.cc | 4 ++-- unittest/imagedata_test.cc | 2 +- unittest/indexmapbidi_test.cc | 2 +- unittest/intfeaturemap_test.cc | 2 +- unittest/intsimdmatrix_test.cc | 2 +- unittest/layout_test.cc | 2 +- unittest/linlsq_test.cc | 4 ++-- unittest/loadlang_test.cc | 4 ++-- unittest/lstm_test.h | 2 +- unittest/mastertrainer_test.cc | 6 +++--- unittest/nthitem_test.cc | 2 +- unittest/pagesegmode_test.cc | 2 +- unittest/progress_test.cc | 4 ++-- unittest/qrsequence_test.cc | 2 +- unittest/recodebeam_test.cc | 4 ++-- unittest/rect_test.cc | 4 ++-- unittest/resultiterator_test.cc | 2 +- unittest/shapetable_test.cc | 2 +- unittest/stats_test.cc | 4 ++-- unittest/stridemap_test.cc | 2 +- unittest/tablefind_test.cc | 4 ++-- unittest/tablerecog_test.cc | 8 ++++---- unittest/tabvector_test.cc | 4 ++-- unittest/textlineprojection_test.cc | 2 +- unittest/tfile_test.cc | 2 +- unittest/unicharcompress_test.cc | 2 +- 32 files changed, 50 insertions(+), 50 deletions(-) diff --git a/unittest/apiexample_test.cc b/unittest/apiexample_test.cc index d9c5631e..8ce720b6 100644 --- a/unittest/apiexample_test.cc +++ b/unittest/apiexample_test.cc @@ -36,10 +36,10 @@ namespace tesseract { class QuickTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { start_time_ = time(nullptr); } - virtual void TearDown() { + void TearDown() override { #ifndef NDEBUG // Debug builds can be very slow, so allow 4 min for OCR of a test image. // apitest_example including disabled tests takes about 18 min on ARMv7. diff --git a/unittest/applybox_test.cc b/unittest/applybox_test.cc index 38d3d23d..6d66fde4 100644 --- a/unittest/applybox_test.cc +++ b/unittest/applybox_test.cc @@ -36,7 +36,7 @@ protected: ApplyBoxTest() { src_pix_ = nullptr; } - ~ApplyBoxTest() { + ~ApplyBoxTest() override { pixDestroy(&src_pix_); } diff --git a/unittest/colpartition_test.cc b/unittest/colpartition_test.cc index 1c0e5902..39c4004b 100644 --- a/unittest/colpartition_test.cc +++ b/unittest/colpartition_test.cc @@ -25,11 +25,11 @@ public: class ColPartitionTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } - void TearDown() {} + void TearDown() override {} }; TEST_F(ColPartitionTest, IsInSameColumnAsReflexive) { diff --git a/unittest/dawg_test.cc b/unittest/dawg_test.cc index 1a2989b5..2703d15c 100644 --- a/unittest/dawg_test.cc +++ b/unittest/dawg_test.cc @@ -33,7 +33,7 @@ namespace tesseract { // aka Directed Acyclic Word Graphs). class DawgTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); file::MakeTmpdir(); } diff --git a/unittest/denorm_test.cc b/unittest/denorm_test.cc index d07eab46..42775cd1 100644 --- a/unittest/denorm_test.cc +++ b/unittest/denorm_test.cc @@ -18,12 +18,12 @@ namespace tesseract { class DENORMTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } public: - void TearDown() {} + void TearDown() override {} void ExpectCorrectTransform(const DENORM &denorm, const TPOINT &src, const TPOINT &result, bool local) { diff --git a/unittest/equationdetect_test.cc b/unittest/equationdetect_test.cc index 0769a782..15009d32 100644 --- a/unittest/equationdetect_test.cc +++ b/unittest/equationdetect_test.cc @@ -120,7 +120,7 @@ protected: // The directory for testdata; std::string testdata_dir_; - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); tesseract_ = std::make_unique(); tesseract_->init_tesseract(TESSDATA_DIR, "eng", OEM_TESSERACT_ONLY); @@ -131,7 +131,7 @@ protected: testdata_dir_ = TESTDATA_DIR; } - void TearDown() { + void TearDown() override { tesseract_.reset(nullptr); equation_det_.reset(nullptr); } diff --git a/unittest/heap_test.cc b/unittest/heap_test.cc index 24f2b930..a1ef5613 100644 --- a/unittest/heap_test.cc +++ b/unittest/heap_test.cc @@ -25,12 +25,12 @@ int test_data[] = {8, 1, 2, -4, 7, 9, 65536, 4, 9, 0}; // The fixture for testing GenericHeap and DoublePtr. class HeapTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } public: - virtual ~HeapTest(); + ~HeapTest() override; // Pushes the test data onto both the heap and the KDVector. void PushTestData(GenericHeap *heap, KDVector *v) { for (size_t i = 0; i < countof(test_data); ++i) { diff --git a/unittest/imagedata_test.cc b/unittest/imagedata_test.cc index 45098854..c5e644d2 100644 --- a/unittest/imagedata_test.cc +++ b/unittest/imagedata_test.cc @@ -25,7 +25,7 @@ namespace tesseract { class ImagedataTest : public ::testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); file::MakeTmpdir(); } diff --git a/unittest/indexmapbidi_test.cc b/unittest/indexmapbidi_test.cc index d4b884af..d3395cee 100644 --- a/unittest/indexmapbidi_test.cc +++ b/unittest/indexmapbidi_test.cc @@ -23,7 +23,7 @@ namespace tesseract { class IndexMapBiDiTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); file::MakeTmpdir(); } diff --git a/unittest/intfeaturemap_test.cc b/unittest/intfeaturemap_test.cc index 3c67e270..45d1b03e 100644 --- a/unittest/intfeaturemap_test.cc +++ b/unittest/intfeaturemap_test.cc @@ -24,7 +24,7 @@ namespace tesseract { class IntFeatureMapTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } diff --git a/unittest/intsimdmatrix_test.cc b/unittest/intsimdmatrix_test.cc index 49fbd1c1..33dbd855 100644 --- a/unittest/intsimdmatrix_test.cc +++ b/unittest/intsimdmatrix_test.cc @@ -28,7 +28,7 @@ namespace tesseract { class IntSimdMatrixTest : public ::testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } diff --git a/unittest/layout_test.cc b/unittest/layout_test.cc index 788aeb9c..3f1bb423 100644 --- a/unittest/layout_test.cc +++ b/unittest/layout_test.cc @@ -64,7 +64,7 @@ protected: LayoutTest() { src_pix_ = nullptr; } - ~LayoutTest() { + ~LayoutTest() override { pixDestroy(&src_pix_); } diff --git a/unittest/linlsq_test.cc b/unittest/linlsq_test.cc index fb459c80..364dd574 100644 --- a/unittest/linlsq_test.cc +++ b/unittest/linlsq_test.cc @@ -17,12 +17,12 @@ namespace tesseract { class LLSQTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } public: - void TearDown() {} + void TearDown() override {} void ExpectCorrectLine(const LLSQ &llsq, double m, double c, double rms, double pearson, double tolerance) { diff --git a/unittest/loadlang_test.cc b/unittest/loadlang_test.cc index a27bfd47..8d3a8fc2 100644 --- a/unittest/loadlang_test.cc +++ b/unittest/loadlang_test.cc @@ -25,10 +25,10 @@ namespace tesseract { class QuickTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { start_time_ = time(nullptr); } - virtual void TearDown() { + void TearDown() override { const time_t end_time = time(nullptr); EXPECT_TRUE(end_time - start_time_ <= 25) << "The test took too long - " << ::testing::PrintToString(end_time - start_time_); diff --git a/unittest/lstm_test.h b/unittest/lstm_test.h index def162e2..e100aad9 100644 --- a/unittest/lstm_test.h +++ b/unittest/lstm_test.h @@ -45,7 +45,7 @@ const int kBatchIterations = 1; // The fixture for testing LSTMTrainer. class LSTMTrainerTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); file::MakeTmpdir(); } diff --git a/unittest/mastertrainer_test.cc b/unittest/mastertrainer_test.cc index 143d8465..4b3e3744 100644 --- a/unittest/mastertrainer_test.cc +++ b/unittest/mastertrainer_test.cc @@ -73,7 +73,7 @@ public: false_unichar_id_ = 67; false_shape_ = shape_table_->AddShape(false_unichar_id_, 25); } - virtual ~MockClassifier() {} + ~MockClassifier() override {} // Classifies the given [training] sample, writing to results. // If debug is non-zero, then various degrees of classifier dependent debug @@ -146,7 +146,7 @@ const double kMin1lDistance = 0.25; class MasterTrainerTest : public testing::Test { #ifndef DISABLED_LEGACY_ENGINE protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); file::MakeTmpdir(); } @@ -162,7 +162,7 @@ protected: shape_table_ = nullptr; master_trainer_ = nullptr; } - ~MasterTrainerTest() { + ~MasterTrainerTest() override { delete shape_table_; } diff --git a/unittest/nthitem_test.cc b/unittest/nthitem_test.cc index 2960022a..68b05740 100644 --- a/unittest/nthitem_test.cc +++ b/unittest/nthitem_test.cc @@ -25,7 +25,7 @@ protected: } public: - virtual ~NthItemTest(); + ~NthItemTest() override; // Pushes the test data onto the KDVector. void PushTestData(KDVector *v) { for (size_t i = 0; i < countof(test_data); ++i) { diff --git a/unittest/pagesegmode_test.cc b/unittest/pagesegmode_test.cc index fc48dde2..030c6bdf 100644 --- a/unittest/pagesegmode_test.cc +++ b/unittest/pagesegmode_test.cc @@ -36,7 +36,7 @@ static bool file_exists(const char *filename) { class PageSegModeTest : public testing::Test { protected: PageSegModeTest() = default; - ~PageSegModeTest() { + ~PageSegModeTest() override { pixDestroy(&src_pix_); } diff --git a/unittest/progress_test.cc b/unittest/progress_test.cc index 39bd37a2..9a1db265 100644 --- a/unittest/progress_test.cc +++ b/unittest/progress_test.cc @@ -36,10 +36,10 @@ namespace tesseract { class QuickTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { start_time_ = time(nullptr); } - virtual void TearDown() { + void TearDown() override { const time_t end_time = time(nullptr); EXPECT_TRUE(end_time - start_time_ <= 25) << "The test took too long - " << ::testing::PrintToString(end_time - start_time_); diff --git a/unittest/qrsequence_test.cc b/unittest/qrsequence_test.cc index 0757ba95..32fd3a02 100644 --- a/unittest/qrsequence_test.cc +++ b/unittest/qrsequence_test.cc @@ -38,7 +38,7 @@ TEST(QRSequenceGenerator, GetBinaryReversedInteger) { // Trivial test fixture for a parameterized test. class QRSequenceGeneratorTest : public ::testing::TestWithParam { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } }; diff --git a/unittest/recodebeam_test.cc b/unittest/recodebeam_test.cc index 08f67e11..2e41f01a 100644 --- a/unittest/recodebeam_test.cc +++ b/unittest/recodebeam_test.cc @@ -59,13 +59,13 @@ const float kVi2ndScores[] = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01}; class RecodeBeamTest : public ::testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); file::MakeTmpdir(); } RecodeBeamTest() : lstm_dict_(&ccutil_) {} - ~RecodeBeamTest() { + ~RecodeBeamTest() override { lstm_dict_.End(); } diff --git a/unittest/rect_test.cc b/unittest/rect_test.cc index c1f60f48..e0d81ee8 100644 --- a/unittest/rect_test.cc +++ b/unittest/rect_test.cc @@ -17,11 +17,11 @@ namespace tesseract { class TBOXTest : public testing::Test { public: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } - void TearDown() {} + void TearDown() override {} }; TEST_F(TBOXTest, OverlapInside) { diff --git a/unittest/resultiterator_test.cc b/unittest/resultiterator_test.cc index b468a93b..fcdea19c 100644 --- a/unittest/resultiterator_test.cc +++ b/unittest/resultiterator_test.cc @@ -31,7 +31,7 @@ protected: ResultIteratorTest() { src_pix_ = nullptr; } - ~ResultIteratorTest() {} + ~ResultIteratorTest() override {} void SetImage(const char *filename) { src_pix_ = pixRead(TestDataNameToPath(filename).c_str()); diff --git a/unittest/shapetable_test.cc b/unittest/shapetable_test.cc index 17ae502a..094d4367 100644 --- a/unittest/shapetable_test.cc +++ b/unittest/shapetable_test.cc @@ -54,7 +54,7 @@ static void Expect352(int font_id, const Shape &shape) { // The fixture for testing Shape. class ShapeTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); file::MakeTmpdir(); } diff --git a/unittest/stats_test.cc b/unittest/stats_test.cc index 91b3d924..47523876 100644 --- a/unittest/stats_test.cc +++ b/unittest/stats_test.cc @@ -20,14 +20,14 @@ const int kTestData[] = {2, 0, 12, 1, 1, 2, 10, 1, 0, 0, 0, 2, 0, 4, 1, 1}; class STATSTest : public testing::Test { public: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); stats_.set_range(0, 16); for (size_t i = 0; i < countof(kTestData); ++i) stats_.add(i, kTestData[i]); } - void TearDown() {} + void TearDown() override {} STATS stats_; }; diff --git a/unittest/stridemap_test.cc b/unittest/stridemap_test.cc index 131bc79e..6782cf91 100644 --- a/unittest/stridemap_test.cc +++ b/unittest/stridemap_test.cc @@ -36,7 +36,7 @@ public: class StridemapTest : public ::testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } diff --git a/unittest/tablefind_test.cc b/unittest/tablefind_test.cc index 8ac24ac9..0d966900 100644 --- a/unittest/tablefind_test.cc +++ b/unittest/tablefind_test.cc @@ -60,7 +60,7 @@ public: class TableFinderTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); free_boxes_it_.set_to_list(&free_boxes_); finder_ = std::make_unique(); @@ -70,7 +70,7 @@ protected: finder_->set_global_median_blob_width(5); } - void TearDown() { + void TearDown() override { if (partition_.get() != nullptr) partition_->DeleteBoxes(); DeletePartitionListBoxes(); diff --git a/unittest/tablerecog_test.cc b/unittest/tablerecog_test.cc index b738098a..ae38097b 100644 --- a/unittest/tablerecog_test.cc +++ b/unittest/tablerecog_test.cc @@ -66,7 +66,7 @@ public: class SharedTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); ICOORD bleft(0, 0); ICOORD tright(1000, 1000); @@ -74,7 +74,7 @@ protected: line_grid_ = std::make_unique(5, bleft, tright); } - void TearDown() { + void TearDown() override { tesseract::ColPartition_IT memory(&allocated_parts_); for (memory.mark_cycle_pt(); !memory.cycled_list(); memory.forward()) { memory.data()->DeleteBoxes(); @@ -141,7 +141,7 @@ protected: class TableRecognizerTest : public SharedTest { protected: - void SetUp() { + void SetUp() override { SharedTest::SetUp(); recognizer_ = std::make_unique(); recognizer_->Init(); @@ -154,7 +154,7 @@ protected: class StructuredTableTest : public SharedTest { protected: - void SetUp() { + void SetUp() override { SharedTest::SetUp(); table_ = std::make_unique(); table_->Init(); diff --git a/unittest/tabvector_test.cc b/unittest/tabvector_test.cc index 8f5d6fa1..f3000f5e 100644 --- a/unittest/tabvector_test.cc +++ b/unittest/tabvector_test.cc @@ -19,12 +19,12 @@ namespace tesseract { class TabVectorTest : public testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); vector_.reset(); } - void TearDown() {} + void TearDown() override {} void MakeSimpleTabVector(int x1, int y1, int x2, int y2) { vector_ = std::make_unique(); diff --git a/unittest/textlineprojection_test.cc b/unittest/textlineprojection_test.cc index ff2d4b5f..f40620b5 100644 --- a/unittest/textlineprojection_test.cc +++ b/unittest/textlineprojection_test.cc @@ -45,7 +45,7 @@ protected: denorm_ = nullptr; projection_ = nullptr; } - virtual ~TextlineProjectionTest() { + ~TextlineProjectionTest() override { pixDestroy(&src_pix_); pixDestroy(&bin_pix_); delete finder_; diff --git a/unittest/tfile_test.cc b/unittest/tfile_test.cc index f7347534..aeb9c782 100644 --- a/unittest/tfile_test.cc +++ b/unittest/tfile_test.cc @@ -20,7 +20,7 @@ namespace tesseract { class TfileTest : public ::testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); } diff --git a/unittest/unicharcompress_test.cc b/unittest/unicharcompress_test.cc index c910d5c4..f6993574 100644 --- a/unittest/unicharcompress_test.cc +++ b/unittest/unicharcompress_test.cc @@ -26,7 +26,7 @@ namespace tesseract { class UnicharcompressTest : public ::testing::Test { protected: - void SetUp() { + void SetUp() override { std::locale::global(std::locale("")); file::MakeTmpdir(); }