Skip to content

Commit

Permalink
unittest: Fix and enable validate_myanmar_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 d67287a commit a6da642
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions unittest/Makefile.am
Expand Up @@ -138,6 +138,7 @@ check_PROGRAMS += unicharcompress_test
check_PROGRAMS += validate_grapheme_test
check_PROGRAMS += validate_indic_test
check_PROGRAMS += validate_khmer_test
check_PROGRAMS += validate_myanmar_test
check_PROGRAMS += validator_test
endif

Expand Down Expand Up @@ -274,6 +275,9 @@ validate_indic_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS
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)

validate_myanmar_test_SOURCES = validate_myanmar_test.cc
validate_myanmar_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
23 changes: 17 additions & 6 deletions unittest/validate_myanmar_test.cc
@@ -1,26 +1,37 @@
#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 Myanmar words.
TEST(ValidateMyanmarTest, GoodMyanmarWords) {
string str = "လျှာကသိသည် "; // No viramas in this one.
std::string str = "လျှာကသိသည် "; // No viramas in this one.
ExpectGraphemeModeResults(str, UnicodeNormMode::kNFC, 11, 11, 5, str);
str = "တုန္လႈပ္မႈ ";
ExpectGraphemeModeResults(str, UnicodeNormMode::kNFC, 11, 9, 4, str);
}

// Test some random Myanmar words with dotted circles.
TEST(ValidateMyanmarTest, BadMyanmarWords) {
string str = "က်န္းမာေရး";
std::vector<string> glyphs;
std::string str = "က်န္းမာေရး";
std::vector<std::string> glyphs;
EXPECT_FALSE(NormalizeCleanAndSegmentUTF8(
UnicodeNormMode::kNFC, OCRNorm::kNone, GraphemeNormMode::kCombined, true,
str.c_str(), &glyphs));
string result;
std::string result;
EXPECT_FALSE(NormalizeUTF8String(UnicodeNormMode::kNFC, OCRNorm::kNone,
GraphemeNorm::kNormalize, str.c_str(),
&result));
Expand Down

0 comments on commit a6da642

Please sign in to comment.