tesseract
5.2.0
Loading...
Searching...
No Matches
colpartition_test.cc
Go to the documentation of this file.
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
12
#include "
colpartition.h
"
13
14
#include "
include_gunit.h
"
15
16
namespace
tesseract
{
17
18
class
TestableColPartition
:
public
ColPartition
{
19
public
:
20
void
SetColumnRange
(
int
first,
int
last
) {
21
set_first_column
(first);
22
set_last_column
(
last
);
23
}
24
};
25
26
class
ColPartitionTest
:
public
testing::Test {
27
protected
:
28
void
SetUp
()
override
{
29
std::locale::global(std::locale(
""
));
30
}
31
32
void
TearDown
()
override
{}
33
};
34
35
TEST_F
(
ColPartitionTest
, IsInSameColumnAsReflexive) {
36
TestableColPartition
a, b;
37
a.
SetColumnRange
(1, 2);
38
b.
SetColumnRange
(3, 3);
39
40
EXPECT_TRUE(a.
IsInSameColumnAs
(a));
41
EXPECT_TRUE(b.
IsInSameColumnAs
(b));
42
}
43
44
TEST_F
(
ColPartitionTest
, IsInSameColumnAsBorders) {
45
TestableColPartition
a, b, c, d;
46
a.
SetColumnRange
(0, 1);
47
b.
SetColumnRange
(1, 2);
48
c.
SetColumnRange
(2, 3);
49
d.
SetColumnRange
(4, 5);
50
51
EXPECT_TRUE(a.
IsInSameColumnAs
(b));
52
EXPECT_TRUE(b.
IsInSameColumnAs
(a));
53
EXPECT_FALSE(c.
IsInSameColumnAs
(d));
54
EXPECT_FALSE(d.
IsInSameColumnAs
(c));
55
EXPECT_FALSE(a.
IsInSameColumnAs
(d));
56
}
57
58
TEST_F
(
ColPartitionTest
, IsInSameColumnAsSuperset) {
59
TestableColPartition
a, b;
60
a.
SetColumnRange
(4, 7);
61
b.
SetColumnRange
(2, 8);
62
63
EXPECT_TRUE(a.
IsInSameColumnAs
(b));
64
EXPECT_TRUE(b.
IsInSameColumnAs
(a));
65
}
66
67
TEST_F
(
ColPartitionTest
, IsInSameColumnAsPartialOverlap) {
68
TestableColPartition
a, b;
69
a.
SetColumnRange
(3, 8);
70
b.
SetColumnRange
(6, 10);
71
72
EXPECT_TRUE(a.
IsInSameColumnAs
(b));
73
EXPECT_TRUE(b.
IsInSameColumnAs
(a));
74
}
75
76
}
// namespace tesseract
colpartition.h
include_gunit.h
tesseract
Definition:
baseapi.h:39
tesseract::last
LIST last(LIST var_list)
Definition:
oldlist.cpp:153
tesseract::TEST_F
TEST_F(EuroText, FastLatinOCR)
Definition:
apiexample_test.cc:105
tesseract::ColPartition
Definition:
colpartition.h:67
tesseract::ColPartition::IsInSameColumnAs
bool IsInSameColumnAs(const ColPartition &part) const
Definition:
colpartition.cpp:2270
tesseract::ColPartition::set_last_column
void set_last_column(int column)
Definition:
colpartition.h:732
tesseract::ColPartition::set_first_column
void set_first_column(int column)
Definition:
colpartition.h:729
tesseract::TestableColPartition
Definition:
colpartition_test.cc:18
tesseract::TestableColPartition::SetColumnRange
void SetColumnRange(int first, int last)
Definition:
colpartition_test.cc:20
tesseract::ColPartitionTest
Definition:
colpartition_test.cc:26
tesseract::ColPartitionTest::TearDown
void TearDown() override
Definition:
colpartition_test.cc:32
tesseract::ColPartitionTest::SetUp
void SetUp() override
Definition:
colpartition_test.cc:28
unittest
colpartition_test.cc
Generated on Tue Mar 21 2023 17:43:28 for tesseract by
1.9.6