12 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
13 FPDF_PAGE page = LoadPage(0);
17 ScopedFPDFTextPage textpage(FPDFText_LoadPage(page));
18 ASSERT_TRUE(textpage);
20 EXPECT_EQ(-2, FPDFText_GetCharIndexFromTextIndex(textpage.get(), -2));
21 EXPECT_EQ(-1, FPDFText_GetCharIndexFromTextIndex(textpage.get(), -1));
22 EXPECT_EQ(0, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 0));
23 EXPECT_EQ(1, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 1));
24 EXPECT_EQ(2, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 2));
25 EXPECT_EQ(5, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 5));
26 EXPECT_EQ(10, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 10));
27 EXPECT_EQ(29, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 29));
28 EXPECT_EQ(-1, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 30));
36 ASSERT_TRUE(OpenDocument(
"bug_1139.pdf"));
37 FPDF_PAGE page = LoadPage(0);
41 ScopedFPDFTextPage textpage(FPDFText_LoadPage(page));
42 ASSERT_TRUE(textpage);
44 EXPECT_EQ(-1, FPDFText_GetCharIndexFromTextIndex(textpage.get(), -2));
45 EXPECT_EQ(0, FPDFText_GetCharIndexFromTextIndex(textpage.get(), -1));
46 EXPECT_EQ(1, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 0));
47 EXPECT_EQ(2, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 1));
48 EXPECT_EQ(3, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 2));
49 EXPECT_EQ(6, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 5));
50 EXPECT_EQ(11, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 10));
51 EXPECT_EQ(30, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 29));
52 EXPECT_EQ(-1, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 30));
53 EXPECT_EQ(-1, FPDFText_GetCharIndexFromTextIndex(textpage.get(), 31));
68 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
69 FPDF_PAGE page = LoadPage(0);
73 ScopedFPDFTextPage textpage(FPDFText_LoadPage(page));
74 ASSERT_TRUE(textpage);
76 EXPECT_EQ(-1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), -2));
77 EXPECT_EQ(-1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), -1));
78 EXPECT_EQ(0, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 0));
79 EXPECT_EQ(1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 1));
80 EXPECT_EQ(2, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 2));
81 EXPECT_EQ(5, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 5));
82 EXPECT_EQ(10, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 10));
83 EXPECT_EQ(29, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 29));
84 EXPECT_EQ(-1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 30));
92 ASSERT_TRUE(OpenDocument(
"bug_1139.pdf"));
93 FPDF_PAGE page = LoadPage(0);
97 ScopedFPDFTextPage textpage(FPDFText_LoadPage(page));
98 ASSERT_TRUE(textpage);
100 EXPECT_EQ(-1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), -2));
101 EXPECT_EQ(-1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), -1));
102 EXPECT_EQ(-1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 0));
103 EXPECT_EQ(0, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 1));
104 EXPECT_EQ(1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 2));
105 EXPECT_EQ(4, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 5));
106 EXPECT_EQ(9, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 10));
107 EXPECT_EQ(28, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 29));
108 EXPECT_EQ(29, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 30));
109 EXPECT_EQ(-1, FPDFText_GetTextIndexFromCharIndex(textpage.get(), 31));