18 #include "allheaders.h"
27 static bool file_exists(
const char* filename) {
29 return _access(filename, 0) == 0;
31 return access(filename, 0) == 0;
36 class PageSegModeTest :
public testing::Test {
38 PageSegModeTest() =
default;
40 pixDestroy(&src_pix_);
43 void SetUp()
override {
44 static std::locale system_locale(
"");
45 std::locale::global(system_locale);
48 void SetImage(
const char* filename) {
49 pixDestroy(&src_pix_);
50 src_pix_ = pixRead(filename);
52 api_.SetImage(src_pix_);
58 int left,
int top,
int width,
int height) {
59 api_.SetPageSegMode(mode);
60 api_.SetRectangle(left, top, width, height);
61 char* result = api_.GetUTF8Text();
64 EXPECT_STREQ(str, result);
71 int left,
int top,
int width,
int height) {
72 api_.SetPageSegMode(mode);
73 api_.SetRectangle(left, top, width, height);
74 char* result = api_.GetUTF8Text();
75 EXPECT_STRNE(str, result);
79 Pix* src_pix_ =
nullptr;
86 TEST_F(PageSegModeTest, WordTest) {
88 if (!file_exists(filename.c_str())) {
89 LOG(
INFO) <<
"Skip test because of missing " << filename <<
'\n';
92 SetImage(filename.c_str());
99 "What should", 237, 393, 256, 36);
102 "Whatshould", 237, 393, 256, 36);
105 "both the\nfrom the", 237, 450, 172, 94);
108 "both the\nfrom the", 237, 450, 172, 94);
110 "both the\nfrom the", 237, 450, 172, 94);