Skip to content

Commit 6b7f7db

Browse files
committed
Fix and enable shapetable_test
Signed-off-by: Stefan Weil <[email protected]>
1 parent bbd23bb commit 6b7f7db

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

unittest/Makefile.am

+7-3
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ check_PROGRAMS = \
124124
progress_test \
125125
qrsequence_test \
126126
rect_test \
127-
stringrenderer_test \
127+
shapetable_test \
128128
stats_test \
129+
stringrenderer_test \
129130
tablefind_test \
130131
tablerecog_test \
131132
tabvector_test \
@@ -255,12 +256,15 @@ qrsequence_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TESS_LIBS)
255256
rect_test_SOURCES = rect_test.cc
256257
rect_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
257258

258-
stringrenderer_test_SOURCES = stringrenderer_test.cc
259-
stringrenderer_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS) -lfontconfig -lpangocairo-1.0 -lpangoft2-1.0 $(cairo_LIBS) $(pango_LIBS)
259+
shapetable_test_SOURCES = shapetable_test.cc
260+
shapetable_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TESS_LIBS)
260261

261262
stats_test_SOURCES = stats_test.cc
262263
stats_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
263264

265+
stringrenderer_test_SOURCES = stringrenderer_test.cc
266+
stringrenderer_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS) -lfontconfig -lpangocairo-1.0 -lpangoft2-1.0 $(cairo_LIBS) $(pango_LIBS)
267+
264268
tablefind_test_SOURCES = tablefind_test.cc
265269
tablefind_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
266270

unittest/shapetable_test.cc

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
// (C) Copyright 2017, Google Inc.
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
111

212
#include <string>
313
#include <utility>
414

5-
#include "tesseract/ccutil/serialis.h"
6-
#include "tesseract/ccutil/unicharset.h"
7-
#include "tesseract/classify/shapetable.h"
15+
#include "absl/strings/str_format.h" // for absl::StrFormat
16+
17+
#include "include_gunit.h"
18+
19+
#include "serialis.h"
20+
#include "shapetable.h"
21+
#include "unicharset.h"
822

923
namespace {
1024

@@ -13,7 +27,7 @@ using tesseract::ShapeTable;
1327
using tesseract::TFile;
1428
using tesseract::UnicharAndFonts;
1529

16-
static string TmpNameToPath(const string& name) {
30+
static std::string TmpNameToPath(const std::string& name) {
1731
return file::JoinPath(FLAGS_test_tmpdir, name);
1832
}
1933

@@ -48,7 +62,7 @@ TEST_F(ShapeTest, BasicTest) {
4862
Setup352(101, &shape1);
4963
Expect352(101, shape1);
5064
// It should still work after file I/O.
51-
string filename = TmpNameToPath("shapefile");
65+
std::string filename = TmpNameToPath("shapefile");
5266
FILE* fp = fopen(filename.c_str(), "wb");
5367
EXPECT_TRUE(fp != nullptr);
5468
EXPECT_TRUE(shape1.Serialize(fp));
@@ -106,7 +120,7 @@ TEST_F(ShapeTableTest, FullTest) {
106120
UNICHARSET unicharset;
107121
unicharset.unichar_insert(" ");
108122
for (int i = 1; i <= 10; ++i) {
109-
string class_str = StringPrintf("class%d", i);
123+
std::string class_str = absl::StrFormat("class%d", i);
110124
unicharset.unichar_insert(class_str.c_str());
111125
}
112126
ShapeTable st(unicharset);

0 commit comments

Comments
 (0)