From 0ae8fdc85936e409179063712dce475402f12131 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 19 Jan 2019 08:34:00 +0100 Subject: [PATCH] Fix build for unicharcompress_test * Add abseil library * Add minimalistic implementation for WriteStringToFile * Add missing namespace for std::string Signed-off-by: Stefan Weil --- unittest/Makefile.am | 2 +- unittest/include_gunit.h | 5 ++++- unittest/unicharcompress_test.cc | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/unittest/Makefile.am b/unittest/Makefile.am index 9805aa5423..d3f8d48b99 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -244,7 +244,7 @@ unichar_test_SOURCES = unichar_test.cc unichar_test_LDADD = $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_UC_LIBS) unicharcompress_test_SOURCES = unicharcompress_test.cc -unicharcompress_test_LDADD = $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_UC_LIBS) +unicharcompress_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_UC_LIBS) unicharset_test_SOURCES = unicharset_test.cc unicharset_test_LDADD = $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_UC_LIBS) diff --git a/unittest/include_gunit.h b/unittest/include_gunit.h index fb9b706e81..ce911b0de6 100644 --- a/unittest/include_gunit.h +++ b/unittest/include_gunit.h @@ -23,7 +23,10 @@ class file : public tesseract::File { public: // Create a file and write a string to it. - static bool WriteStringToFile(const std::string& contents, const std::string& name); + static bool WriteStringToFile(const std::string& contents, const std::string& filename) { + File::WriteStringToFileOrDie(contents, filename); + return true; + } static bool GetContents(const std::string& filename, std::string* out, int) { return File::ReadFileToString(filename, out); diff --git a/unittest/unicharcompress_test.cc b/unittest/unicharcompress_test.cc index b7e42aa2dd..b36db1f262 100644 --- a/unittest/unicharcompress_test.cc +++ b/unittest/unicharcompress_test.cc @@ -237,7 +237,7 @@ TEST_F(UnicharcompressTest, GetEncodingAsString) { ExpectCorrect("trivial"); STRING encoding = compressed_.GetEncodingAsString(unicharset_); std::string encoding_str(&encoding[0], encoding.length()); - std::vector lines = + std::vector lines = absl::StrSplit(encoding_str, "\n", absl::SkipEmpty()); EXPECT_EQ(5, lines.size()); // The first line is always space.