23#ifndef DISABLED_LEGACY_ENGINE
25static std::string TmpNameToPath(
const std::string &name) {
30static void Setup352(
int font_id, Shape *shape) {
31 shape->AddToShape(3, font_id);
32 shape->AddToShape(5, font_id);
33 shape->AddToShape(2, font_id);
37static void Expect352(
int font_id,
const Shape &shape) {
38 EXPECT_EQ(3, shape.size());
39 EXPECT_TRUE(shape.ContainsUnichar(2));
40 EXPECT_TRUE(shape.ContainsUnichar(3));
41 EXPECT_TRUE(shape.ContainsUnichar(5));
42 EXPECT_FALSE(shape.ContainsUnichar(1));
43 EXPECT_TRUE(shape.ContainsUnicharAndFont(2, font_id));
44 EXPECT_FALSE(shape.ContainsUnicharAndFont(2, font_id - 1));
45 EXPECT_FALSE(shape.ContainsUnicharAndFont(font_id, 2));
47 EXPECT_TRUE(shape.IsSubsetOf(shape));
56 std::locale::global(std::locale(
""));
63#ifdef DISABLED_LEGACY_ENGINE
68 EXPECT_EQ(0, shape1.
size());
69 Setup352(101, &shape1);
70 Expect352(101, shape1);
72 std::string filename = TmpNameToPath(
"shapefile");
73 FILE *fp = fopen(filename.c_str(),
"wb");
74 ASSERT_TRUE(fp !=
nullptr);
78 EXPECT_TRUE(tfp.
Open(filename.c_str(),
nullptr));
81 Expect352(101, shape2);
88 Expect352(101, shape1);
89 Expect352(101, shape2);
95#ifdef DISABLED_LEGACY_ENGINE
100 Setup352(101, &shape1);
101 Expect352(101, shape1);
115 EXPECT_EQ(4, shape1.
size());
130#ifdef DISABLED_LEGACY_ENGINE
135 Setup352(101, &shape1);
139 for (
int i = 1; i <= 10; ++i) {
141 snprintf(class_str,
sizeof(class_str),
"class%d", i);
149 Expect352(101, shape1);
151 for (
int i = 0; i < 3; ++i) {
164 for (
int i = 0; i < 3; ++i) {
TEST_F(EuroText, FastLatinOCR)
bool Open(const char *filename, FileReader reader)
void unichar_insert(const char *const unichar_repr, OldUncleanUnichars old_style)
bool IsSubsetOf(const Shape &other) const
bool ContainsUnicharAndFont(int unichar_id, int font_id) const
void AddToShape(int unichar_id, int font_id)
bool Serialize(FILE *fp) const
void AddShape(const Shape &other)
bool IsEqualUnichars(Shape *other)
bool DeSerialize(TFile *fp)
bool ContainsUnichar(int unichar_id) const
bool AnyMultipleUnichars() const
Shape * MutableShape(unsigned shape_id)
int MergedUnicharCount(unsigned shape_id1, unsigned shape_id2) const
unsigned AddShape(int unichar_id, int font_id)
int NumMasterShapes() const
unsigned MasterDestinationIndex(unsigned shape_id) const
int MasterFontCount(unsigned shape_id) const
unsigned NumShapes() const
void DeleteShape(unsigned shape_id)
void MergeShapes(unsigned shape_id1, unsigned shape_id2)
unsigned MasterUnicharCount(unsigned shape_id) const
void AppendMasterShapes(const ShapeTable &other, std::vector< int > *shape_map)
static std::string JoinPath(const std::string &s1, const std::string &s2)