| Code-Review | +1 |
ASSERT_EQ(5, FPDFPage_CountObjects(page.get()));kExpectedText.size()? Same below.
FPDFTextObj_GetText(text_object, text_page.get(), nullptr, i);This param is supposed to be the length of the buffer, which is nullptr. Just set to 0?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
ASSERT_EQ(5, FPDFPage_CountObjects(page.get()));Lei ZhangkExpectedText.size()? Same below.
Something like that. Done.
FPDFTextObj_GetText(text_object, text_page.get(), nullptr, i);This param is supposed to be the length of the buffer, which is nullptr. Just set to 0?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: fpdfsdk/fpdf_text_embeddertest.cpp
Insertions: 12, Deletions: 10.
@@ -1453,13 +1453,15 @@
}
TEST_F(FPDFTextEmbedderTest, GetTextShouldNotGetInvisibleSpaces) {
- static constexpr std::array<std::wstring_view, 5> kExpectedText = {
- std::wstring_view(L""),
- std::wstring_view(L""),
- std::wstring_view(L""),
- std::wstring_view(L"Hello, world!"),
- std::wstring_view(L"Goodbye, world!"),
- };
+ static constexpr int kExpectedPageObjectCount = 5;
+ static constexpr std::array<std::wstring_view, kExpectedPageObjectCount>
+ kExpectedText = {
+ std::wstring_view(L""),
+ std::wstring_view(L""),
+ std::wstring_view(L""),
+ std::wstring_view(L"Hello, world!"),
+ std::wstring_view(L"Goodbye, world!"),
+ };
ASSERT_TRUE(OpenDocument("hello_world_with_invisible_spaces.pdf"));
ScopedPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
@@ -1467,14 +1469,14 @@
ScopedFPDFTextPage text_page(FPDFText_LoadPage(page.get()));
ASSERT_TRUE(text_page);
- ASSERT_EQ(5, FPDFPage_CountObjects(page.get()));
- for (int i = 0; i < 5; ++i) {
+ ASSERT_EQ(kExpectedPageObjectCount, FPDFPage_CountObjects(page.get()));
+ for (int i = 0; i < kExpectedPageObjectCount; ++i) {
SCOPED_TRACE(testing::Message() << "Object " << i);
FPDF_PAGEOBJECT text_object = FPDFPage_GetObject(page.get(), i);
ASSERT_TRUE(text_object);
unsigned long size =
- FPDFTextObj_GetText(text_object, text_page.get(), nullptr, i);
+ FPDFTextObj_GetText(text_object, text_page.get(), nullptr, 0);
// `size` is in bytes and includes the terminating NUL.
ASSERT_EQ(2 * (kExpectedText[i].size() + 1), size);
```
Add a regression test for FPDFTextObj_GetText() and space characters
Add hello_world_with_invisible_spaces.pdf, which is a copy of
hello_world.pdf with some extra spaces. Add a new
FPDFTextEmbedderTest.GetTextShouldNotGetInvisibleSpaces test case to
check this new PDF and make sure the extra spaces within do not get
extracted.
Simplify the adjacent FPDFTextEmbedderTest.GetText test case along the
way.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |