Skip to content

Commit

Permalink
unittest: Fix and enable validate_khmer_test
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jan 23, 2019
1 parent 611d5e6 commit d67287a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions unittest/Makefile.am
Expand Up @@ -137,6 +137,7 @@ check_PROGRAMS += unicharset_test
check_PROGRAMS += unicharcompress_test
check_PROGRAMS += validate_grapheme_test
check_PROGRAMS += validate_indic_test
check_PROGRAMS += validate_khmer_test
check_PROGRAMS += validator_test
endif

Expand Down Expand Up @@ -270,6 +271,9 @@ validate_grapheme_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(T
validate_indic_test_SOURCES = validate_indic_test.cc
validate_indic_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)

validate_khmer_test_SOURCES = validate_khmer_test.cc
validate_khmer_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)

validator_test_SOURCES = validator_test.cc
validator_test_LDADD = $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_UC_LIBS)

Expand Down
21 changes: 16 additions & 5 deletions unittest/validate_khmer_test.cc
@@ -1,13 +1,24 @@
#include "tesseract/training/normstrngs.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 "tesseract/unittest/normstrngs_test.h"
#include "include_gunit.h"
#include "normstrngs.h"
#include "normstrngs_test.h"

namespace tesseract {
namespace {

// Test some random Khmer words.
TEST(ValidateKhmerTest, GoodKhmerWords) {
string str = "ព័ត៏មានប្លែកៗ";
std::string str = "ព័ត៏មានប្លែកៗ";
ExpectGraphemeModeResults(str, UnicodeNormMode::kNFC, 13, 12, 7, str);
str = "ទំនុកច្រៀង";
ExpectGraphemeModeResults(str, UnicodeNormMode::kNFC, 10, 9, 5, str);
Expand All @@ -19,9 +30,9 @@ TEST(ValidateKhmerTest, GoodKhmerWords) {

// Test some random Khmer words with dotted circles.
TEST(ValidateKhmerTest, BadKhmerWords) {
string result;
std::string result;
// Multiple dependent vowels not allowed
string str = "\u1796\u17b6\u17b7";
std::string str = "\u1796\u17b6\u17b7";
EXPECT_FALSE(NormalizeUTF8String(UnicodeNormMode::kNFC, OCRNorm::kNone,
GraphemeNorm::kNormalize, str.c_str(),
&result));
Expand Down

0 comments on commit d67287a

Please sign in to comment.