mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-24 02:59:07 +08:00
unittest: Fix tests which need Tensorflow headers
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
89de2bfcea
commit
5409299763
@ -43,6 +43,9 @@ endif
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/viewer
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/wordrec
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/abseil
|
||||
if TENSORFLOW
|
||||
AM_CPPFLAGS += -DINCLUDE_TENSORFLOW
|
||||
endif
|
||||
|
||||
# Build googletest:
|
||||
check_LTLIBRARIES = libgtest.la libgtest_main.la libgmock.la libgmock_main.la
|
||||
@ -158,7 +161,9 @@ check_PROGRAMS += lstm_squashed_test
|
||||
check_PROGRAMS += lstm_test
|
||||
check_PROGRAMS += lstmtrainer_test
|
||||
check_PROGRAMS += normstrngs_test
|
||||
if TENSORFLOW
|
||||
check_PROGRAMS += pango_font_info_test
|
||||
endif
|
||||
check_PROGRAMS += unichar_test
|
||||
check_PROGRAMS += unicharcompress_test
|
||||
check_PROGRAMS += unicharset_test
|
||||
@ -273,7 +278,9 @@ matrix_test_SOURCES = matrix_test.cc
|
||||
matrix_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
|
||||
normstrngs_test_SOURCES = normstrngs_test.cc
|
||||
if TENSORFLOW
|
||||
normstrngs_test_SOURCES += third_party/utf/rune.c util/utf8/unilib.cc
|
||||
endif
|
||||
normstrngs_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
|
||||
|
||||
nthitem_test_SOURCES = nthitem_test.cc
|
||||
@ -282,6 +289,7 @@ nthitem_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
osd_test_SOURCES = osd_test.cc
|
||||
osd_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)
|
||||
|
||||
if TENSORFLOW
|
||||
pango_font_info_test_SOURCES = pango_font_info_test.cc
|
||||
pango_font_info_test_SOURCES += third_party/utf/rune.c
|
||||
pango_font_info_test_SOURCES += util/utf8/unicodetext.cc util/utf8/unilib.cc
|
||||
@ -289,6 +297,7 @@ pango_font_info_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(LEP
|
||||
pango_font_info_test_LDADD += $(ICU_I18N_LIBS) -lfontconfig
|
||||
pango_font_info_test_LDADD += -lpangocairo-1.0 -lpangoft2-1.0
|
||||
pango_font_info_test_LDADD += $(cairo_LIBS) $(pango_LIBS)
|
||||
endif
|
||||
|
||||
paragraphs_test_SOURCES = paragraphs_test.cc
|
||||
paragraphs_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TESS_LIBS)
|
||||
|
@ -15,7 +15,9 @@
|
||||
#include "normstrngs_test.h"
|
||||
#include "strngs.h"
|
||||
#include "unichar.h"
|
||||
#include "util/utf8/unilib.h"
|
||||
#ifdef INCLUDE_TENSORFLOW
|
||||
#include "util/utf8/unilib.h" // for UniLib
|
||||
#endif
|
||||
|
||||
#include "include_gunit.h"
|
||||
|
||||
@ -364,18 +366,22 @@ TEST(NormstrngsTest, SpanUTF8NotWhitespace) {
|
||||
// Test that the method clones the util/utf8/public/unilib definition of
|
||||
// interchange validity.
|
||||
TEST(NormstrngsTest, IsInterchangeValid) {
|
||||
#ifdef INCLUDE_TENSORFLOW
|
||||
const int32_t kMinUnicodeValue = 33;
|
||||
const int32_t kMaxUnicodeValue = 0x10FFFF;
|
||||
for (int32_t ch = kMinUnicodeValue; ch <= kMaxUnicodeValue; ++ch) {
|
||||
SCOPED_TRACE(absl::StrFormat("Failed at U+%x", ch));
|
||||
EXPECT_EQ(UniLib::IsInterchangeValid(ch), IsInterchangeValid(ch));
|
||||
}
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Test that the method clones the util/utf8/public/unilib definition of
|
||||
// 7-bit ASCII interchange validity.
|
||||
TEST(NormstrngsTest, IsInterchangeValid7BitAscii) {
|
||||
#if defined(MISSING_CODE)
|
||||
#if defined(MISSING_CODE) && defined(INCLUDE_TENSORFLOW)
|
||||
const int32_t kMinUnicodeValue = 33;
|
||||
const int32_t kMaxUnicodeValue = 0x10FFFF;
|
||||
for (int32_t ch = kMinUnicodeValue; ch <= kMaxUnicodeValue; ++ch) {
|
||||
@ -400,7 +406,7 @@ TEST(NormstrngsTest, FullwidthToHalfwidth) {
|
||||
// U+FFE6 -> U+20A9 (won sign)
|
||||
EXPECT_EQ(0x20A9, FullwidthToHalfwidth(0xFFE6));
|
||||
|
||||
#if defined(MISSING_CODE)
|
||||
#if defined(MISSING_CODE) && defined(INCLUDE_TENSORFLOW)
|
||||
// Skipped because of missing UniLib::FullwidthToHalfwidth.
|
||||
const int32_t kMinUnicodeValue = 33;
|
||||
const int32_t kMaxUnicodeValue = 0x10FFFF;
|
||||
|
Loading…
Reference in New Issue
Block a user