mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
Merge pull request #1866 from stweil/unittests
Fix and enable two more unit tests
This commit is contained in:
commit
5b31213764
@ -21,6 +21,9 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/dict
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/display
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/lstm
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/textord
|
||||
if ENABLE_TRAINING
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/training
|
||||
endif
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/viewer
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/wordrec
|
||||
|
||||
@ -47,6 +50,9 @@ libgmock_main_la_CPPFLAGS = $(GMOCK_INCLUDES) \
|
||||
GTEST_LIBS = libgtest.la libgtest_main.la
|
||||
GMOCK_LIBS = libgmock.la libgmock_main.la
|
||||
TESS_LIBS = $(top_builddir)/src/api/libtesseract.la
|
||||
TRAINING_LIBS = $(top_builddir)/src/training/libtesseract_training.la
|
||||
TRAINING_LIBS += $(top_builddir)/src/training/libtesseract_tessopt.la
|
||||
TRAINING_LIBS += $(ICU_UC_LIBS)
|
||||
AM_CPPFLAGS += -isystem $(top_srcdir)/googletest/googletest/include \
|
||||
-isystem $(top_srcdir)/googletest/googlemock/include
|
||||
|
||||
@ -74,6 +80,11 @@ check_PROGRAMS = \
|
||||
tfile_test \
|
||||
tesseracttests
|
||||
|
||||
if ENABLE_TRAINING
|
||||
check_PROGRAMS += commandlineflags_test
|
||||
check_PROGRAMS += validator_test
|
||||
endif
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
# List of source files needed to build the executable:
|
||||
@ -91,6 +102,9 @@ cleanapi_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
colpartition_test_SOURCES = colpartition_test.cc
|
||||
colpartition_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
|
||||
commandlineflags_test_SOURCES = commandlineflags_test.cc
|
||||
commandlineflags_test_LDADD = $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS)
|
||||
|
||||
denorm_test_SOURCES = denorm_test.cc
|
||||
denorm_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
|
||||
@ -140,11 +154,14 @@ tablerecog_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
tabvector_test_SOURCES = tabvector_test.cc
|
||||
tabvector_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
|
||||
tesseracttests_SOURCES = ../tests/tesseracttests.cpp
|
||||
tesseracttests_LDADD = $(GTEST_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)
|
||||
|
||||
tfile_test_SOURCES = tfile_test.cc
|
||||
tfile_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
|
||||
tesseracttests_SOURCES = ../tests/tesseracttests.cpp
|
||||
tesseracttests_LDADD = $(GTEST_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)
|
||||
validator_test_SOURCES = validator_test.cc
|
||||
validator_test_LDADD = $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS)
|
||||
|
||||
# for windows
|
||||
if T_WIN
|
||||
|
@ -1,5 +1,17 @@
|
||||
#include "tesseract/training/commandlineflags.h"
|
||||
// (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 "commandlineflags.h"
|
||||
|
||||
#include "include_gunit.h"
|
||||
|
||||
// Flags used for testing parser.
|
||||
INT_PARAM_FLAG(foo_int, 0, "Integer flag for testing");
|
||||
@ -44,12 +56,14 @@ TEST_F(CommandlineflagsTest, RemoveFlags) {
|
||||
EXPECT_STREQ("file2.h", argv[2]);
|
||||
}
|
||||
|
||||
#if 0 // TODO: this test needs an update (it currently fails).
|
||||
TEST_F(CommandlineflagsTest, PrintUsageAndExit) {
|
||||
const char* argv[] = { "Progname", "--help" };
|
||||
EXPECT_EXIT(TestParser("Progname [flags]", ARRAYSIZE(argv), argv),
|
||||
::testing::ExitedWithCode(0),
|
||||
"USAGE: Progname \\[flags\\]");
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(CommandlineflagsTest, ExitsWithErrorOnInvalidFlag) {
|
||||
const char* argv[] = { "", "--test_nonexistent_flag" };
|
||||
|
@ -1,4 +1,18 @@
|
||||
#include "tesseract/training/validator.h"
|
||||
// (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 "validator.h"
|
||||
|
||||
#include "include_gunit.h"
|
||||
#include "gmock/gmock.h" // for testing::ElementsAreArray
|
||||
|
||||
namespace tesseract {
|
||||
namespace {
|
||||
|
Loading…
Reference in New Issue
Block a user