Modernize code (clang-tidy -checks='-*,modernize-use-override')

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-03-22 08:26:05 +01:00
parent 7bada4e629
commit cb80eb6963
32 changed files with 50 additions and 50 deletions

View File

@ -36,10 +36,10 @@ namespace tesseract {
class QuickTest : public testing::Test { class QuickTest : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
start_time_ = time(nullptr); start_time_ = time(nullptr);
} }
virtual void TearDown() { void TearDown() override {
#ifndef NDEBUG #ifndef NDEBUG
// Debug builds can be very slow, so allow 4 min for OCR of a test image. // 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. // apitest_example including disabled tests takes about 18 min on ARMv7.

View File

@ -36,7 +36,7 @@ protected:
ApplyBoxTest() { ApplyBoxTest() {
src_pix_ = nullptr; src_pix_ = nullptr;
} }
~ApplyBoxTest() { ~ApplyBoxTest() override {
pixDestroy(&src_pix_); pixDestroy(&src_pix_);
} }

View File

@ -25,11 +25,11 @@ public:
class ColPartitionTest : public testing::Test { class ColPartitionTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }
void TearDown() {} void TearDown() override {}
}; };
TEST_F(ColPartitionTest, IsInSameColumnAsReflexive) { TEST_F(ColPartitionTest, IsInSameColumnAsReflexive) {

View File

@ -33,7 +33,7 @@ namespace tesseract {
// aka Directed Acyclic Word Graphs). // aka Directed Acyclic Word Graphs).
class DawgTest : public testing::Test { class DawgTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
file::MakeTmpdir(); file::MakeTmpdir();
} }

View File

@ -18,12 +18,12 @@ namespace tesseract {
class DENORMTest : public testing::Test { class DENORMTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }
public: public:
void TearDown() {} void TearDown() override {}
void ExpectCorrectTransform(const DENORM &denorm, const TPOINT &src, const TPOINT &result, void ExpectCorrectTransform(const DENORM &denorm, const TPOINT &src, const TPOINT &result,
bool local) { bool local) {

View File

@ -120,7 +120,7 @@ protected:
// The directory for testdata; // The directory for testdata;
std::string testdata_dir_; std::string testdata_dir_;
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
tesseract_ = std::make_unique<Tesseract>(); tesseract_ = std::make_unique<Tesseract>();
tesseract_->init_tesseract(TESSDATA_DIR, "eng", OEM_TESSERACT_ONLY); tesseract_->init_tesseract(TESSDATA_DIR, "eng", OEM_TESSERACT_ONLY);
@ -131,7 +131,7 @@ protected:
testdata_dir_ = TESTDATA_DIR; testdata_dir_ = TESTDATA_DIR;
} }
void TearDown() { void TearDown() override {
tesseract_.reset(nullptr); tesseract_.reset(nullptr);
equation_det_.reset(nullptr); equation_det_.reset(nullptr);
} }

View File

@ -25,12 +25,12 @@ int test_data[] = {8, 1, 2, -4, 7, 9, 65536, 4, 9, 0};
// The fixture for testing GenericHeap and DoublePtr. // The fixture for testing GenericHeap and DoublePtr.
class HeapTest : public testing::Test { class HeapTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }
public: public:
virtual ~HeapTest(); ~HeapTest() override;
// Pushes the test data onto both the heap and the KDVector. // Pushes the test data onto both the heap and the KDVector.
void PushTestData(GenericHeap<IntKDPair> *heap, KDVector *v) { void PushTestData(GenericHeap<IntKDPair> *heap, KDVector *v) {
for (size_t i = 0; i < countof(test_data); ++i) { for (size_t i = 0; i < countof(test_data); ++i) {

View File

@ -25,7 +25,7 @@ namespace tesseract {
class ImagedataTest : public ::testing::Test { class ImagedataTest : public ::testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
file::MakeTmpdir(); file::MakeTmpdir();
} }

View File

@ -23,7 +23,7 @@ namespace tesseract {
class IndexMapBiDiTest : public testing::Test { class IndexMapBiDiTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
file::MakeTmpdir(); file::MakeTmpdir();
} }

View File

@ -24,7 +24,7 @@ namespace tesseract {
class IntFeatureMapTest : public testing::Test { class IntFeatureMapTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }

View File

@ -28,7 +28,7 @@ namespace tesseract {
class IntSimdMatrixTest : public ::testing::Test { class IntSimdMatrixTest : public ::testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }

View File

@ -64,7 +64,7 @@ protected:
LayoutTest() { LayoutTest() {
src_pix_ = nullptr; src_pix_ = nullptr;
} }
~LayoutTest() { ~LayoutTest() override {
pixDestroy(&src_pix_); pixDestroy(&src_pix_);
} }

View File

@ -17,12 +17,12 @@ namespace tesseract {
class LLSQTest : public testing::Test { class LLSQTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }
public: public:
void TearDown() {} void TearDown() override {}
void ExpectCorrectLine(const LLSQ &llsq, double m, double c, double rms, double pearson, void ExpectCorrectLine(const LLSQ &llsq, double m, double c, double rms, double pearson,
double tolerance) { double tolerance) {

View File

@ -25,10 +25,10 @@ namespace tesseract {
class QuickTest : public testing::Test { class QuickTest : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
start_time_ = time(nullptr); start_time_ = time(nullptr);
} }
virtual void TearDown() { void TearDown() override {
const time_t end_time = time(nullptr); const time_t end_time = time(nullptr);
EXPECT_TRUE(end_time - start_time_ <= 25) EXPECT_TRUE(end_time - start_time_ <= 25)
<< "The test took too long - " << ::testing::PrintToString(end_time - start_time_); << "The test took too long - " << ::testing::PrintToString(end_time - start_time_);

View File

@ -45,7 +45,7 @@ const int kBatchIterations = 1;
// The fixture for testing LSTMTrainer. // The fixture for testing LSTMTrainer.
class LSTMTrainerTest : public testing::Test { class LSTMTrainerTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
file::MakeTmpdir(); file::MakeTmpdir();
} }

View File

@ -73,7 +73,7 @@ public:
false_unichar_id_ = 67; false_unichar_id_ = 67;
false_shape_ = shape_table_->AddShape(false_unichar_id_, 25); false_shape_ = shape_table_->AddShape(false_unichar_id_, 25);
} }
virtual ~MockClassifier() {} ~MockClassifier() override {}
// Classifies the given [training] sample, writing to results. // Classifies the given [training] sample, writing to results.
// If debug is non-zero, then various degrees of classifier dependent debug // 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 { class MasterTrainerTest : public testing::Test {
#ifndef DISABLED_LEGACY_ENGINE #ifndef DISABLED_LEGACY_ENGINE
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
file::MakeTmpdir(); file::MakeTmpdir();
} }
@ -162,7 +162,7 @@ protected:
shape_table_ = nullptr; shape_table_ = nullptr;
master_trainer_ = nullptr; master_trainer_ = nullptr;
} }
~MasterTrainerTest() { ~MasterTrainerTest() override {
delete shape_table_; delete shape_table_;
} }

View File

@ -25,7 +25,7 @@ protected:
} }
public: public:
virtual ~NthItemTest(); ~NthItemTest() override;
// Pushes the test data onto the KDVector. // Pushes the test data onto the KDVector.
void PushTestData(KDVector *v) { void PushTestData(KDVector *v) {
for (size_t i = 0; i < countof(test_data); ++i) { for (size_t i = 0; i < countof(test_data); ++i) {

View File

@ -36,7 +36,7 @@ static bool file_exists(const char *filename) {
class PageSegModeTest : public testing::Test { class PageSegModeTest : public testing::Test {
protected: protected:
PageSegModeTest() = default; PageSegModeTest() = default;
~PageSegModeTest() { ~PageSegModeTest() override {
pixDestroy(&src_pix_); pixDestroy(&src_pix_);
} }

View File

@ -36,10 +36,10 @@ namespace tesseract {
class QuickTest : public testing::Test { class QuickTest : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
start_time_ = time(nullptr); start_time_ = time(nullptr);
} }
virtual void TearDown() { void TearDown() override {
const time_t end_time = time(nullptr); const time_t end_time = time(nullptr);
EXPECT_TRUE(end_time - start_time_ <= 25) EXPECT_TRUE(end_time - start_time_ <= 25)
<< "The test took too long - " << ::testing::PrintToString(end_time - start_time_); << "The test took too long - " << ::testing::PrintToString(end_time - start_time_);

View File

@ -38,7 +38,7 @@ TEST(QRSequenceGenerator, GetBinaryReversedInteger) {
// Trivial test fixture for a parameterized test. // Trivial test fixture for a parameterized test.
class QRSequenceGeneratorTest : public ::testing::TestWithParam<int> { class QRSequenceGeneratorTest : public ::testing::TestWithParam<int> {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }
}; };

View File

@ -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 { class RecodeBeamTest : public ::testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
file::MakeTmpdir(); file::MakeTmpdir();
} }
RecodeBeamTest() : lstm_dict_(&ccutil_) {} RecodeBeamTest() : lstm_dict_(&ccutil_) {}
~RecodeBeamTest() { ~RecodeBeamTest() override {
lstm_dict_.End(); lstm_dict_.End();
} }

View File

@ -17,11 +17,11 @@ namespace tesseract {
class TBOXTest : public testing::Test { class TBOXTest : public testing::Test {
public: public:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }
void TearDown() {} void TearDown() override {}
}; };
TEST_F(TBOXTest, OverlapInside) { TEST_F(TBOXTest, OverlapInside) {

View File

@ -31,7 +31,7 @@ protected:
ResultIteratorTest() { ResultIteratorTest() {
src_pix_ = nullptr; src_pix_ = nullptr;
} }
~ResultIteratorTest() {} ~ResultIteratorTest() override {}
void SetImage(const char *filename) { void SetImage(const char *filename) {
src_pix_ = pixRead(TestDataNameToPath(filename).c_str()); src_pix_ = pixRead(TestDataNameToPath(filename).c_str());

View File

@ -54,7 +54,7 @@ static void Expect352(int font_id, const Shape &shape) {
// The fixture for testing Shape. // The fixture for testing Shape.
class ShapeTest : public testing::Test { class ShapeTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
file::MakeTmpdir(); file::MakeTmpdir();
} }

View File

@ -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 { class STATSTest : public testing::Test {
public: public:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
stats_.set_range(0, 16); stats_.set_range(0, 16);
for (size_t i = 0; i < countof(kTestData); ++i) for (size_t i = 0; i < countof(kTestData); ++i)
stats_.add(i, kTestData[i]); stats_.add(i, kTestData[i]);
} }
void TearDown() {} void TearDown() override {}
STATS stats_; STATS stats_;
}; };

View File

@ -36,7 +36,7 @@ public:
class StridemapTest : public ::testing::Test { class StridemapTest : public ::testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }

View File

@ -60,7 +60,7 @@ public:
class TableFinderTest : public testing::Test { class TableFinderTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
free_boxes_it_.set_to_list(&free_boxes_); free_boxes_it_.set_to_list(&free_boxes_);
finder_ = std::make_unique<TestableTableFinder>(); finder_ = std::make_unique<TestableTableFinder>();
@ -70,7 +70,7 @@ protected:
finder_->set_global_median_blob_width(5); finder_->set_global_median_blob_width(5);
} }
void TearDown() { void TearDown() override {
if (partition_.get() != nullptr) if (partition_.get() != nullptr)
partition_->DeleteBoxes(); partition_->DeleteBoxes();
DeletePartitionListBoxes(); DeletePartitionListBoxes();

View File

@ -66,7 +66,7 @@ public:
class SharedTest : public testing::Test { class SharedTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
ICOORD bleft(0, 0); ICOORD bleft(0, 0);
ICOORD tright(1000, 1000); ICOORD tright(1000, 1000);
@ -74,7 +74,7 @@ protected:
line_grid_ = std::make_unique<ColPartitionGrid>(5, bleft, tright); line_grid_ = std::make_unique<ColPartitionGrid>(5, bleft, tright);
} }
void TearDown() { void TearDown() override {
tesseract::ColPartition_IT memory(&allocated_parts_); tesseract::ColPartition_IT memory(&allocated_parts_);
for (memory.mark_cycle_pt(); !memory.cycled_list(); memory.forward()) { for (memory.mark_cycle_pt(); !memory.cycled_list(); memory.forward()) {
memory.data()->DeleteBoxes(); memory.data()->DeleteBoxes();
@ -141,7 +141,7 @@ protected:
class TableRecognizerTest : public SharedTest { class TableRecognizerTest : public SharedTest {
protected: protected:
void SetUp() { void SetUp() override {
SharedTest::SetUp(); SharedTest::SetUp();
recognizer_ = std::make_unique<TestableTableRecognizer>(); recognizer_ = std::make_unique<TestableTableRecognizer>();
recognizer_->Init(); recognizer_->Init();
@ -154,7 +154,7 @@ protected:
class StructuredTableTest : public SharedTest { class StructuredTableTest : public SharedTest {
protected: protected:
void SetUp() { void SetUp() override {
SharedTest::SetUp(); SharedTest::SetUp();
table_ = std::make_unique<TestableStructuredTable>(); table_ = std::make_unique<TestableStructuredTable>();
table_->Init(); table_->Init();

View File

@ -19,12 +19,12 @@ namespace tesseract {
class TabVectorTest : public testing::Test { class TabVectorTest : public testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
vector_.reset(); vector_.reset();
} }
void TearDown() {} void TearDown() override {}
void MakeSimpleTabVector(int x1, int y1, int x2, int y2) { void MakeSimpleTabVector(int x1, int y1, int x2, int y2) {
vector_ = std::make_unique<TabVector>(); vector_ = std::make_unique<TabVector>();

View File

@ -45,7 +45,7 @@ protected:
denorm_ = nullptr; denorm_ = nullptr;
projection_ = nullptr; projection_ = nullptr;
} }
virtual ~TextlineProjectionTest() { ~TextlineProjectionTest() override {
pixDestroy(&src_pix_); pixDestroy(&src_pix_);
pixDestroy(&bin_pix_); pixDestroy(&bin_pix_);
delete finder_; delete finder_;

View File

@ -20,7 +20,7 @@ namespace tesseract {
class TfileTest : public ::testing::Test { class TfileTest : public ::testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
} }

View File

@ -26,7 +26,7 @@ namespace tesseract {
class UnicharcompressTest : public ::testing::Test { class UnicharcompressTest : public ::testing::Test {
protected: protected:
void SetUp() { void SetUp() override {
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
file::MakeTmpdir(); file::MakeTmpdir();
} }