Skip to content

Commit

Permalink
unittest: Fix and enable bitvector_test
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Aug 25, 2018
1 parent 2b7df59 commit 0dc5c8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
7 changes: 5 additions & 2 deletions unittest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,25 @@ AM_CPPFLAGS += -isystem $(top_srcdir)/googletest/googletest/include \

check_PROGRAMS = \
apiexample_test \
bitvector_test \
progress_test \
intsimdmatrix_test \
matrix_test \
osd_test \
loadlang_test \
tesseracttests


TESTS = $(check_PROGRAMS)

#List of source files needed to build the executable:
# List of source files needed to build the executable:

apiexample_test_SOURCES = apiexample_test.cc
apiexample_test_LDFLAGS = $(OPENCL_LDFLAGS) $(LEPTONICA_LIBS)
apiexample_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)

bitvector_test_SOURCES = bitvector_test.cc
bitvector_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)

progress_test_SOURCES = progress_test.cc
progress_test_LDFLAGS = $(OPENCL_LDFLAGS) $(LEPTONICA_LIBS)
progress_test_LDADD = $(GTEST_LIBS) $(GMOCK_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)
Expand Down
23 changes: 18 additions & 5 deletions unittest/bitvector_test.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
// (C) Copyright 2017, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <math.h>
#include <stdio.h>
#include <cmath>
#include <cstdio>
#include <string>
#include "tesseract/ccutil/bitvector.h"

#include "bitvector.h"

#include "include_gunit.h"

using tesseract::BitVector;

Expand All @@ -12,7 +25,7 @@ namespace {

class BitVectorTest : public testing::Test {
public:
string OutputNameToPath(const string& name) {
std::string OutputNameToPath(const std::string& name) {
return file::JoinPath(FLAGS_test_tmpdir, name);
}
// Computes primes upto kPrimeLimit, using the seive of Eratosthenes.
Expand Down Expand Up @@ -103,7 +116,7 @@ TEST_F(BitVectorTest, Primes) {
map3 = map;
TestPrimes(map3);
// Test file i/o too.
string filename = OutputNameToPath("primesbitvector");
std::string filename = OutputNameToPath("primesbitvector");
FILE* fp = fopen(filename.c_str(), "wb");
CHECK(fp != nullptr);
EXPECT_TRUE(map.Serialize(fp));
Expand Down

0 comments on commit 0dc5c8e

Please sign in to comment.