summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdftext_embeddertest.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-10-24 08:36:44 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-10-24 17:56:53 +0000
commit65f3162c91607071322967ea064a4a11e3904722 (patch)
treef02b548e74dedb2c85ef974559bf686b2f2c70fd /fpdfsdk/fpdftext_embeddertest.cpp
parent1d8d9ac983fa9c7b6dfc3df736cfd3eae6908a60 (diff)
downloadpdfium-65f3162c91607071322967ea064a4a11e3904722.tar.xz
Add more tests for FPDFText methods.
BUG=pdfium:921 Change-Id: I6973359e6ac112c56843f66eb0b70462f42f9cae Reviewed-on: https://pdfium-review.googlesource.com/16630 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdftext_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdftext_embeddertest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/fpdfsdk/fpdftext_embeddertest.cpp b/fpdfsdk/fpdftext_embeddertest.cpp
index 7e8e033ae0..1536c8679b 100644
--- a/fpdfsdk/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/fpdftext_embeddertest.cpp
@@ -494,3 +494,34 @@ TEST_F(FPDFTextEmbeddertest, ToUnicode) {
FPDFText_ClosePage(textpage);
UnloadPage(page);
}
+
+TEST_F(FPDFTextEmbeddertest, Bug_921) {
+ EXPECT_TRUE(OpenDocument("bug_921.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_TRUE(page);
+
+ FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page);
+ EXPECT_TRUE(textpage);
+
+ static constexpr unsigned int kData[] = {
+ 1095, 1077, 1083, 1086, 1074, 1077, 1095, 1077, 1089, 1082, 1086, 1077,
+ 32, 1089, 1090, 1088, 1072, 1076, 1072, 1085, 1080, 1077, 46, 32};
+ static constexpr int kStartIndex = 238;
+
+ ASSERT_EQ(268, FPDFText_CountChars(textpage));
+ for (size_t i = 0; i < FX_ArraySize(kData); ++i)
+ EXPECT_EQ(kData[i], FPDFText_GetUnicode(textpage, kStartIndex + i));
+
+ unsigned short buffer[FX_ArraySize(kData) + 1];
+ memset(buffer, 0xbd, sizeof(buffer));
+ int count =
+ FPDFText_GetText(textpage, kStartIndex, FX_ArraySize(buffer), buffer);
+ ASSERT_GT(count, 0);
+ ASSERT_EQ(FX_ArraySize(kData) + 1, static_cast<size_t>(count));
+ for (size_t i = 0; i < FX_ArraySize(kData); ++i)
+ EXPECT_EQ(kData[i], buffer[i]);
+ EXPECT_EQ(0, buffer[FX_ArraySize(kData)]);
+
+ FPDFText_ClosePage(textpage);
+ UnloadPage(page);
+}