Skip to content

Commit c4eda83

Browse files
committed
unittest: Fix and enable indexmapbidi_test
Signed-off-by: Stefan Weil <[email protected]>
1 parent de7676c commit c4eda83

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

unittest/Makefile.am

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ check_PROGRAMS = \
5757
colpartition_test \
5858
denorm_test \
5959
heap_test \
60+
indexmapbidi_test \
6061
progress_test \
6162
intsimdmatrix_test \
6263
matrix_test \
@@ -87,6 +88,9 @@ denorm_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
8788
heap_test_SOURCES = heap_test.cc
8889
heap_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
8990

91+
indexmapbidi_test_SOURCES = indexmapbidi_test.cc
92+
indexmapbidi_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
93+
9094
progress_test_SOURCES = progress_test.cc
9195
progress_test_LDFLAGS = $(OPENCL_LDFLAGS) $(LEPTONICA_LIBS)
9296
progress_test_LDADD = $(GTEST_LIBS) $(GMOCK_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)

unittest/indexmapbidi_test.cc

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
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

2-
#include <math.h>
3-
#include <stdio.h>
12+
#include <cmath>
13+
#include <cstdio>
414
#include <string>
5-
#include "tesseract/ccutil/indexmapbidi.h"
15+
16+
#include "indexmapbidi.h"
17+
18+
#include "include_gunit.h"
619

720
using tesseract::IndexMap;
821
using tesseract::IndexMapBiDi;
@@ -13,7 +26,7 @@ namespace {
1326

1427
class IndexMapBiDiTest : public testing::Test {
1528
public:
16-
string OutputNameToPath(const string& name) {
29+
std::string OutputNameToPath(const std::string& name) {
1730
return file::JoinPath(FLAGS_test_tmpdir, name);
1831
}
1932
// Computes primes upto kPrimeLimit, using the seive of Eratosthenes.
@@ -66,7 +79,7 @@ TEST_F(IndexMapBiDiTest, Primes) {
6679
base_map.CopyFrom(map);
6780
TestPrimes(base_map);
6881
// Test file i/o too.
69-
string filename = OutputNameToPath("primesmap");
82+
std::string filename = OutputNameToPath("primesmap");
7083
FILE* fp = fopen(filename.c_str(), "wb");
7184
CHECK(fp != nullptr);
7285
EXPECT_TRUE(map.Serialize(fp));
@@ -101,7 +114,3 @@ TEST_F(IndexMapBiDiTest, ManyToOne) {
101114
}
102115

103116
} // namespace.
104-
105-
106-
107-

0 commit comments

Comments
 (0)