Skip to content

Commit 04d85b4

Browse files
committed
Add more test code for normstrngs_test
unilib.h is now available, so more code can be enabled. Signed-off-by: Stefan Weil <[email protected]>
1 parent aa54bf0 commit 04d85b4

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

unittest/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ matrix_test_SOURCES = matrix_test.cc
273273
matrix_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
274274

275275
normstrngs_test_SOURCES = normstrngs_test.cc
276+
normstrngs_test_SOURCES += third_party/utf/rune.c util/utf8/unilib.cc
276277
normstrngs_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
277278

278279
nthitem_test_SOURCES = nthitem_test.cc

unittest/normstrngs_test.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@
1515
#include "normstrngs_test.h"
1616
#include "strngs.h"
1717
#include "unichar.h"
18-
#if defined(HAS_UNILIB_H)
19-
#include "unilib.h"
20-
#endif
18+
#include "util/utf8/unilib.h"
2119

2220
#include "include_gunit.h"
2321

2422
namespace tesseract {
2523
namespace {
2624

27-
#if defined(HAS_UNILIB_H)
25+
#if defined(MISSING_CODE)
2826
static std::string EncodeAsUTF8(const char32 ch32) {
2927
UNICHAR uni_ch(ch32);
3028
return std::string(uni_ch.utf8(), uni_ch.utf8_len());
@@ -363,7 +361,6 @@ TEST(NormstrngsTest, SpanUTF8NotWhitespace) {
363361
EXPECT_EQ(12, SpanUTF8NotWhitespace(kMixedText));
364362
}
365363

366-
#if defined(HAS_UNILIB_H)
367364
// Test that the method clones the util/utf8/public/unilib definition of
368365
// interchange validity.
369366
TEST(NormstrngsTest, IsInterchangeValid) {
@@ -374,12 +371,11 @@ TEST(NormstrngsTest, IsInterchangeValid) {
374371
EXPECT_EQ(UniLib::IsInterchangeValid(ch), IsInterchangeValid(ch));
375372
}
376373
}
377-
#endif
378374

379-
#if defined(HAS_UNILIB_H)
380375
// Test that the method clones the util/utf8/public/unilib definition of
381376
// 7-bit ASCII interchange validity.
382377
TEST(NormstrngsTest, IsInterchangeValid7BitAscii) {
378+
#if defined(MISSING_CODE)
383379
const int32_t kMinUnicodeValue = 33;
384380
const int32_t kMaxUnicodeValue = 0x10FFFF;
385381
for (int32_t ch = kMinUnicodeValue; ch <= kMaxUnicodeValue; ++ch) {
@@ -388,8 +384,11 @@ TEST(NormstrngsTest, IsInterchangeValid7BitAscii) {
388384
EXPECT_EQ(UniLib::IsInterchangeValid7BitAscii(str),
389385
IsInterchangeValid7BitAscii(ch));
390386
}
391-
}
387+
#else
388+
// Skipped because of missing UniLib::IsInterchangeValid7BitAscii.
389+
GTEST_SKIP();
392390
#endif
391+
}
393392

394393
// Test that the method clones the util/utf8/public/unilib definition of
395394
// fullwidth-halfwidth .
@@ -401,7 +400,8 @@ TEST(NormstrngsTest, FullwidthToHalfwidth) {
401400
// U+FFE6 -> U+20A9 (won sign)
402401
EXPECT_EQ(0x20A9, FullwidthToHalfwidth(0xFFE6));
403402

404-
#if defined(HAS_UNILIB_H)
403+
#if defined(MISSING_CODE)
404+
// Skipped because of missing UniLib::FullwidthToHalfwidth.
405405
const int32_t kMinUnicodeValue = 33;
406406
const int32_t kMaxUnicodeValue = 0x10FFFF;
407407
for (int32_t ch = kMinUnicodeValue; ch <= kMaxUnicodeValue; ++ch) {

0 commit comments

Comments
 (0)