提交 87707bb8 编写于 作者: S Stefan Weil

unittest: Remove dependency on absl::StrSplit()

Signed-off-by: NStefan Weil <sw@weilnetz.de>
上级 f407345c
......@@ -1192,7 +1192,6 @@ libabseil_la_SOURCES += abseil/absl/strings/internal/str_format/output.cc
libabseil_la_SOURCES += abseil/absl/strings/internal/str_format/parser.cc
libabseil_la_SOURCES += abseil/absl/strings/match.cc
libabseil_la_SOURCES += abseil/absl/strings/numbers.cc
libabseil_la_SOURCES += abseil/absl/strings/str_split.cc
libabseil_la_SOURCES += abseil/absl/strings/string_view.cc
libabseil_la_CPPFLAGS = -I$(top_srcdir)/abseil
......@@ -1372,7 +1371,7 @@ endif # !DISABLED_LEGACY_ENGINE
fileio_test_SOURCES = unittest/fileio_test.cc
fileio_test_CPPFLAGS = $(unittest_CPPFLAGS)
fileio_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS)
fileio_test_LDADD = $(TRAINING_LIBS)
heap_test_SOURCES = unittest/heap_test.cc
heap_test_CPPFLAGS = $(unittest_CPPFLAGS)
......@@ -1450,7 +1449,7 @@ lstmtrainer_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(LEPTONICA_LIBS)
if !DISABLED_LEGACY_ENGINE
mastertrainer_test_SOURCES = unittest/mastertrainer_test.cc
mastertrainer_test_CPPFLAGS = $(unittest_CPPFLAGS)
mastertrainer_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(LEPTONICA_LIBS)
mastertrainer_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
endif # !DISABLED_LEGACY_ENGINE
matrix_test_SOURCES = unittest/matrix_test.cc
......@@ -1497,7 +1496,7 @@ pango_font_info_test_LDADD += $(pangoft2_LIBS)
paragraphs_test_SOURCES = unittest/paragraphs_test.cc
paragraphs_test_CPPFLAGS = $(unittest_CPPFLAGS)
paragraphs_test_LDADD = $(ABSEIL_LIBS) $(TESS_LIBS)
paragraphs_test_LDADD = $(TESS_LIBS)
if !DISABLED_LEGACY_ENGINE
params_model_test_SOURCES = unittest/params_model_test.cc
......@@ -1547,7 +1546,7 @@ stridemap_test_LDADD = $(TESS_LIBS)
stringrenderer_test_SOURCES = unittest/stringrenderer_test.cc
stringrenderer_test_CPPFLAGS = $(unittest_CPPFLAGS)
stringrenderer_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(LEPTONICA_LIBS)
stringrenderer_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
stringrenderer_test_LDADD += $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
stringrenderer_test_LDADD += $(pangocairo_LIBS) $(pangoft2_LIBS)
stringrenderer_test_LDADD += $(cairo_LIBS) $(pango_LIBS)
......@@ -1587,7 +1586,7 @@ unichar_test_LDADD = $(TRAINING_LIBS) $(ICU_UC_LIBS)
unicharcompress_test_SOURCES = unittest/unicharcompress_test.cc
unicharcompress_test_CPPFLAGS = $(unittest_CPPFLAGS)
unicharcompress_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(ICU_UC_LIBS)
unicharcompress_test_LDADD = $(TRAINING_LIBS) $(ICU_UC_LIBS)
unicharset_test_SOURCES = unittest/unicharset_test.cc
unicharset_test_CPPFLAGS = $(unittest_CPPFLAGS)
......
......@@ -12,8 +12,6 @@
#include <stdio.h>
#include <memory>
#include "absl/strings/str_split.h"
#include "fileio.h"
#include "include_gunit.h"
......@@ -58,7 +56,7 @@ TEST(InputBufferTest, Read) {
std::string str;
auto input = std::make_unique<InputBuffer>(fp);
EXPECT_TRUE(input->Read(&str));
std::vector<std::string> lines = absl::StrSplit(str, '\n', absl::SkipEmpty());
std::vector<std::string> lines = split(str, '\n');
EXPECT_EQ(2, lines.size());
EXPECT_EQ("Hello", lines[0]);
EXPECT_EQ(" world!", lines[1]);
......
......@@ -32,8 +32,6 @@
#include "trainingsample.h"
#include "unicharset.h"
#include "absl/strings/str_split.h" // for absl::StrSplit
#include <string>
#include <utility>
#include <vector>
......@@ -267,7 +265,7 @@ TEST_F(MasterTrainerTest, ErrorCounterTest) {
shape_classifier.get(), &accuracy_report);
LOG(INFO) << accuracy_report.c_str();
std::string result_string = accuracy_report.c_str();
std::vector<std::string> results = absl::StrSplit(result_string, '\t', absl::SkipEmpty());
std::vector<std::string> results = split(result_string, '\t');
EXPECT_EQ(tesseract::CT_SIZE + 1, results.size());
int result_values[tesseract::CT_SIZE];
for (int i = 0; i < tesseract::CT_SIZE; ++i) {
......
......@@ -11,8 +11,6 @@
#include <string> // for std::string
#include "absl/strings/str_split.h" // for absl::StrSplit
#include "include_gunit.h" // for TEST
#include "log.h" // for LOG
......@@ -60,7 +58,7 @@ void AsciiToRowInfo(const char *text, int row_number, RowInfo *info) {
info->lword_text = info->rword_text = "";
info->ltr = true;
std::vector<std::string> words = absl::StrSplit(text, ' ', absl::SkipEmpty());
std::vector<std::string> words = split(text, ' ');
info->num_words = words.size();
if (info->num_words < 1) {
return;
......
......@@ -17,7 +17,6 @@
#include "stringrenderer.h"
#include <allheaders.h>
#include "absl/strings/str_split.h" // for absl::StrSplit
#include <memory>
#include <string>
......@@ -348,7 +347,7 @@ TEST_F(StringRendererTest, DoesRenderWordBoxes) {
EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix));
pix.destroy();
// Verify #boxchars = #words + #spaces
std::vector<std::string> words = absl::StrSplit(kEngText, ' ', absl::SkipEmpty());
std::vector<std::string> words = split(kEngText, ' ');
const int kNumSpaces = words.size() - 1;
const int kExpectedNumBoxes = words.size() + kNumSpaces;
const std::vector<BoxChar *> &boxchars = renderer_->GetBoxes();
......@@ -371,8 +370,12 @@ TEST_F(StringRendererTest, DoesRenderWordBoxesFromMultiLineText) {
EXPECT_EQ(strlen(kMultlineText), renderer_->RenderToImage(kMultlineText, strlen(kEngText), &pix));
pix.destroy();
// Verify #boxchars = #words + #spaces + #newlines
std::vector<std::string> words =
absl::StrSplit(kMultlineText, absl::ByAnyChar(" \n"), absl::SkipEmpty());
std::vector<std::string> words;
for (auto &line : split(kMultlineText, '\n')) {
for (auto &word : split(line, ' ')) {
words.push_back(word);
}
}
const int kNumSeparators = words.size() - 1;
const int kExpectedNumBoxes = words.size() + kNumSeparators;
const std::vector<BoxChar *> &boxchars = renderer_->GetBoxes();
......
......@@ -12,8 +12,6 @@
#include <string>
#include <allheaders.h>
#include "absl/strings/ascii.h"
#include "absl/strings/str_split.h"
#include "include_gunit.h"
#include "log.h" // for LOG
......@@ -232,7 +230,7 @@ TEST_F(UnicharcompressTest, GetEncodingAsString) {
ExpectCorrect("trivial");
std::string encoding = compressed_.GetEncodingAsString(unicharset_);
std::string encoding_str(&encoding[0], encoding.length());
std::vector<std::string> lines = absl::StrSplit(encoding_str, "\n", absl::SkipEmpty());
std::vector<std::string> lines = split(encoding_str, '\n');
EXPECT_EQ(5, lines.size());
// The first line is always space.
EXPECT_EQ("0\t ", lines[0]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册