From d67287a5d9c4415de84cf8d5f86e5ba36582308c Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 22 Jan 2019 15:22:30 +0100 Subject: [PATCH] unittest: Fix and enable validate_khmer_test Signed-off-by: Stefan Weil --- unittest/Makefile.am | 4 ++++ unittest/validate_khmer_test.cc | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/unittest/Makefile.am b/unittest/Makefile.am index ce014b9c08..327c3fb93b 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -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 @@ -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) diff --git a/unittest/validate_khmer_test.cc b/unittest/validate_khmer_test.cc index 34afc4097f..4798932ad5 100644 --- a/unittest/validate_khmer_test.cc +++ b/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); @@ -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));