Skip to content

Commit

Permalink
Remove global array kPolyBlockNames from Tesseract library
Browse files Browse the repository at this point in the history
It is only used in unittest/layout_test.cc after moving a test from
baseapi_test.cc to that file, so it can be made local.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Aug 12, 2019
1 parent c757b4e commit bce5852
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/ccstruct/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ libtesseract_ccstruct_la_SOURCES = \
linlsq.cpp matrix.cpp mod128.cpp normalis.cpp \
ocrblock.cpp ocrpara.cpp ocrrow.cpp otsuthr.cpp \
pageres.cpp pdblock.cpp points.cpp polyaprx.cpp polyblk.cpp \
params_training_featdef.cpp publictypes.cpp \
params_training_featdef.cpp \
quadlsq.cpp quspline.cpp ratngs.cpp rect.cpp rejctmap.cpp \
seam.cpp split.cpp statistc.cpp stepblob.cpp \
vecfuncs.cpp werd.cpp
40 changes: 0 additions & 40 deletions src/ccstruct/publictypes.cpp

This file was deleted.

6 changes: 1 addition & 5 deletions src/ccstruct/publictypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// File: publictypes.h
// Description: Types used in both the API and internally
// Author: Ray Smith
// Created: Wed Mar 03 09:22:53 PST 2010
//
// (C) Copyright 2010, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -47,7 +46,7 @@ constexpr int kResolutionEstimationFactor = 10;
/**
* Possible types for a POLY_BLOCK or ColPartition.
* Must be kept in sync with kPBColors in polyblk.cpp and PTIs*Type functions
* below, as well as kPolyBlockNames in publictypes.cpp.
* below, as well as kPolyBlockNames in layout_test.cc.
* Used extensively by ColPartition, and POLY_BLOCK.
*/
enum PolyBlockType {
Expand Down Expand Up @@ -90,9 +89,6 @@ inline bool PTIsPulloutType(PolyBlockType type) {
return type == PT_PULLOUT_IMAGE || type == PT_PULLOUT_TEXT;
}

/** String name for each block type. Keep in sync with PolyBlockType. */
extern const char* kPolyBlockNames[];

namespace tesseract {
/**
* +------------------+ Orientation Example:
Expand Down
8 changes: 0 additions & 8 deletions unittest/baseapi_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ class TesseractTest : public testing::Test {
}
};

// Tests that array sizes match their intended size.
TEST_F(TesseractTest, ArraySizeTest) {
int size = 0;
for (size = 0; kPolyBlockNames[size][0] != '\0'; ++size)
;
EXPECT_EQ(size, PT_COUNT);
}

// Tests that Tesseract gets exactly the right answer on phototest.
TEST_F(TesseractTest, BasicTesseractTest) {
tesseract::TessBaseAPI api;
Expand Down
28 changes: 28 additions & 0 deletions unittest/layout_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ using tesseract::MutableIterator;
using tesseract::PageIteratorLevel;
using tesseract::ResultIterator;

/** String name for each block type. Keep in sync with PolyBlockType. */
static const char* kPolyBlockNames[] = {
"Unknown",
"Flowing Text",
"Heading Text",
"Pullout Text",
"Equation",
"Inline Equation",
"Table",
"Vertical Text",
"Caption Text",
"Flowing Image",
"Heading Image",
"Pullout Image",
"Horizontal Line",
"Vertical Line",
"Noise",
"" // End marker for testing that sizes match.
};

const char* kStrings8087_054[] = {
"dat", "Dalmatian", "", "DAMAGED DURING", "margarine,", nullptr};
const PolyBlockType kBlocks8087_054[] = {PT_HEADING_TEXT, PT_FLOWING_TEXT,
Expand Down Expand Up @@ -171,6 +191,14 @@ class LayoutTest : public testing::Test {
tesseract::TessBaseAPI api_;
};

// Tests that array sizes match their intended size.
TEST_F(LayoutTest, ArraySizeTest) {
int size = 0;
for (size = 0; kPolyBlockNames[size][0] != '\0'; ++size)
;
EXPECT_EQ(size, PT_COUNT);
}

// Tests that Tesseract gets the important blocks and in the right order
// on a UNLV page numbered 8087_054.3B.tif. (Dubrovnik)
TEST_F(LayoutTest, UNLV8087_054) {
Expand Down

0 comments on commit bce5852

Please sign in to comment.