Skip to content

Commit 420a028

Browse files
committed
unittest: Add fileio_test
Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent d3cf423 commit 420a028

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

unittest/Makefile.am

+7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ libabseil_la_SOURCES += ../abseil/absl/base/internal/throw_delegate.cc
4747
libabseil_la_SOURCES += ../abseil/absl/base/internal/unscaledcycleclock.cc
4848
libabseil_la_SOURCES += ../abseil/absl/numeric/int128.cc
4949
libabseil_la_SOURCES += ../abseil/absl/strings/ascii.cc
50+
libabseil_la_SOURCES += ../abseil/absl/strings/internal/memutil.cc
5051
libabseil_la_SOURCES += ../abseil/absl/strings/str_cat.cc
52+
libabseil_la_SOURCES += ../abseil/absl/strings/str_split.cc
53+
libabseil_la_SOURCES += ../abseil/absl/strings/string_view.cc
5154
libabseil_la_SOURCES += ../abseil/absl/time/clock.cc
5255
libabseil_la_SOURCES += ../abseil/absl/time/duration.cc
5356

@@ -82,6 +85,7 @@ check_PROGRAMS = \
8285
cleanapi_test \
8386
colpartition_test \
8487
denorm_test \
88+
fileio_test \
8589
heap_test \
8690
indexmapbidi_test \
8791
intfeaturemap_test \
@@ -138,6 +142,9 @@ commandlineflags_test_LDADD = $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS)
138142
denorm_test_SOURCES = denorm_test.cc
139143
denorm_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
140144

145+
fileio_test_SOURCES = fileio_test.cc
146+
fileio_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TESS_LIBS)
147+
141148
heap_test_SOURCES = heap_test.cc
142149
heap_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
143150

unittest/fileio_test.cc

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1-
#include "tesseract/training/fileio.h"
1+
// (C) Copyright 2017, Google Inc.
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
212

313
#include <stdio.h>
414
#include <memory>
515

16+
#include "absl/strings/str_split.h"
17+
18+
#include "fileio.h"
19+
#include "include_gunit.h"
20+
621
namespace {
722

823
using tesseract::File;
@@ -38,10 +53,10 @@ TEST(InputBufferTest, Read) {
3853
FILE* fp = fmemopen(buffer, kMaxBufSize, "r");
3954
CHECK(fp != nullptr);
4055

41-
string str;
56+
std::string str;
4257
std::unique_ptr<InputBuffer> input(new InputBuffer(fp));
4358
EXPECT_TRUE(input->Read(&str));
44-
std::vector<string> lines = absl::StrSplit(str, '\n', absl::SkipEmpty());
59+
std::vector<std::string> lines = absl::StrSplit(str, '\n', absl::SkipEmpty());
4560
EXPECT_EQ(2, lines.size());
4661
EXPECT_EQ("Hello", lines[0]);
4762
EXPECT_EQ(" world!", lines[1]);

0 commit comments

Comments
 (0)