mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-23 18:49:08 +08:00
unittest: Remove dependency on absl::StrFormat()
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
fe5ca9dad9
commit
8486f59493
@ -1535,7 +1535,7 @@ scanutils_test_LDADD = $(TRAINING_LIBS)
|
||||
if !DISABLED_LEGACY_ENGINE
|
||||
shapetable_test_SOURCES = unittest/shapetable_test.cc
|
||||
shapetable_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
||||
shapetable_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS)
|
||||
shapetable_test_LDADD = $(TRAINING_LIBS)
|
||||
endif # !DISABLED_LEGACY_ENGINE
|
||||
|
||||
stats_test_SOURCES = unittest/stats_test.cc
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
|
||||
#include "imagedata.h"
|
||||
#include "include_gunit.h"
|
||||
@ -42,7 +41,9 @@ protected:
|
||||
DocumentData write_doc("My document");
|
||||
for (int p = 0; p < num_pages; ++p) {
|
||||
// Make some fake text that is different for each page and save it.
|
||||
page_texts->push_back(absl::StrFormat("Page %d of %d in doc %u", p, num_pages, doc_id));
|
||||
char text[80];
|
||||
snprintf(text, sizeof(text), "Page %d of %d in doc %u", p, num_pages, doc_id);
|
||||
page_texts->push_back(text);
|
||||
// Make an imagedata and put it in the document.
|
||||
ImageData *imagedata = ImageData::Build("noname", p, "eng", fake_image.data(),
|
||||
fake_image.size(), (*page_texts)[p].c_str(), nullptr);
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "normstrngs.h"
|
||||
#include <tesseract/unichar.h>
|
||||
#include "absl/strings/str_format.h" // for absl::StrFormat
|
||||
#include "include_gunit.h"
|
||||
#include "normstrngs_test.h"
|
||||
#ifdef INCLUDE_TENSORFLOW
|
||||
@ -315,7 +314,9 @@ TEST(NormstrngsTest, IsWhitespace) {
|
||||
EXPECT_TRUE(IsWhitespace('\n'));
|
||||
// U+2000 through U+200A
|
||||
for (char32 ch = 0x2000; ch <= 0x200A; ++ch) {
|
||||
SCOPED_TRACE(absl::StrFormat("Failed at U+%x", ch));
|
||||
char text[80];
|
||||
snprintf(text, sizeof(text), "Failed at U+%x", ch);
|
||||
SCOPED_TRACE(text);
|
||||
EXPECT_TRUE(IsWhitespace(ch));
|
||||
}
|
||||
// U+3000 is whitespace
|
||||
@ -354,7 +355,9 @@ TEST(NormstrngsTest, IsInterchangeValid) {
|
||||
const int32_t kMinUnicodeValue = 33;
|
||||
const int32_t kMaxUnicodeValue = 0x10FFFF;
|
||||
for (int32_t ch = kMinUnicodeValue; ch <= kMaxUnicodeValue; ++ch) {
|
||||
SCOPED_TRACE(absl::StrFormat("Failed at U+%x", ch));
|
||||
char text[80];
|
||||
snprintf(text, sizeof(text), "Failed at U+%x", ch);
|
||||
SCOPED_TRACE(text);
|
||||
EXPECT_EQ(UniLib::IsInterchangeValid(ch), IsInterchangeValid(ch));
|
||||
}
|
||||
#else
|
||||
@ -369,7 +372,9 @@ TEST(NormstrngsTest, IsInterchangeValid7BitAscii) {
|
||||
const int32_t kMinUnicodeValue = 33;
|
||||
const int32_t kMaxUnicodeValue = 0x10FFFF;
|
||||
for (int32_t ch = kMinUnicodeValue; ch <= kMaxUnicodeValue; ++ch) {
|
||||
SCOPED_TRACE(absl::StrFormat("Failed at U+%x", ch));
|
||||
char text[80];
|
||||
snprintf(text, sizeof(text), "Failed at U+%x", ch);
|
||||
SCOPED_TRACE(text);
|
||||
std::string str = EncodeAsUTF8(ch);
|
||||
EXPECT_EQ(UniLib::IsInterchangeValid7BitAscii(str), IsInterchangeValid7BitAscii(ch));
|
||||
}
|
||||
@ -396,7 +401,9 @@ TEST(NormstrngsTest, FullwidthToHalfwidth) {
|
||||
for (int32_t ch = kMinUnicodeValue; ch <= kMaxUnicodeValue; ++ch) {
|
||||
if (!IsValidCodepoint(ch))
|
||||
continue;
|
||||
SCOPED_TRACE(absl::StrFormat("Failed at U+%x", ch));
|
||||
char text[80];
|
||||
snprintf(text, sizeof(text), "Failed at U+%x", ch);
|
||||
SCOPED_TRACE(text);
|
||||
std::string str = EncodeAsUTF8(ch);
|
||||
const std::string expected_half_str =
|
||||
UniLib::FullwidthToHalfwidth(str.c_str(), str.length(), true);
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/strings/str_format.h" // for absl::StrFormat
|
||||
|
||||
#include "include_gunit.h"
|
||||
|
||||
#include "serialis.h"
|
||||
@ -139,8 +137,9 @@ TEST_F(ShapeTableTest, FullTest) {
|
||||
UNICHARSET unicharset;
|
||||
unicharset.unichar_insert(" ");
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
std::string class_str = absl::StrFormat("class%d", i);
|
||||
unicharset.unichar_insert(class_str.c_str());
|
||||
char class_str[20];
|
||||
snprintf(class_str, sizeof(class_str), "class%d", i);
|
||||
unicharset.unichar_insert(class_str);
|
||||
}
|
||||
ShapeTable st(unicharset);
|
||||
EXPECT_EQ(0, st.AddShape(3, 101));
|
||||
|
Loading…
Reference in New Issue
Block a user