summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdftext_embeddertest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-11-25 15:37:53 -0800
committerTom Sepez <tsepez@chromium.org>2015-11-25 15:37:53 -0800
commitc3e4ae5fe5067723b58a2029a95c6411c92bed15 (patch)
tree1544bf8fa786c92a009efc8974886027403c676e /fpdfsdk/src/fpdftext_embeddertest.cpp
parent3caa6537663e85ad6874c4420907d2ab885c80ea (diff)
downloadpdfium-c3e4ae5fe5067723b58a2029a95c6411c92bed15.tar.xz
Merge to master: Take Jun's UTF16LE patches.
(cherry picked from commit 8d89e65897d8b6cf7899e7a82d9d381c3ad327cb) (cherry picked from commit c70b19aad245fb1ed39bf8c264d991555f4c5a58) BUG=pdfium:275 TBR=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/1473753004 .
Diffstat (limited to 'fpdfsdk/src/fpdftext_embeddertest.cpp')
-rw-r--r--fpdfsdk/src/fpdftext_embeddertest.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/fpdfsdk/src/fpdftext_embeddertest.cpp b/fpdfsdk/src/fpdftext_embeddertest.cpp
index 6c1ae4ceb8..50eef87341 100644
--- a/fpdfsdk/src/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/src/fpdftext_embeddertest.cpp
@@ -42,8 +42,9 @@ TEST_F(FPDFTextEmbeddertest, Text) {
// Check includes the terminating NUL that is provided.
int num_chars = FPDFText_GetText(textpage, 0, 128, fixed_buffer);
ASSERT_GE(num_chars, 0);
- EXPECT_EQ(sizeof(expected), static_cast<size_t>(num_chars));
- EXPECT_TRUE(check_unsigned_shorts(expected, fixed_buffer, sizeof(expected)));
+ EXPECT_EQ(sizeof(expected) - 1, static_cast<size_t>(num_chars));
+ EXPECT_TRUE(
+ check_unsigned_shorts(expected, fixed_buffer, sizeof(expected) - 1));
// Count does not include the terminating NUL in the string literal.
EXPECT_EQ(sizeof(expected) - 1, FPDFText_CountChars(textpage));
@@ -125,11 +126,10 @@ TEST_F(FPDFTextEmbeddertest, Text) {
EXPECT_EQ(0xbdbd, fixed_buffer[9]);
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(10, FPDFText_GetBoundedText(textpage, 41.0, 56.0, 82.0, 48.0,
- fixed_buffer, 128));
+ EXPECT_EQ(9, FPDFText_GetBoundedText(textpage, 41.0, 56.0, 82.0, 48.0,
+ fixed_buffer, 128));
EXPECT_TRUE(check_unsigned_shorts(expected + 4, fixed_buffer, 9));
- EXPECT_EQ(0u, fixed_buffer[9]);
- EXPECT_EQ(0xbdbd, fixed_buffer[10]);
+ EXPECT_EQ(0xbdbd, fixed_buffer[9]);
FPDFText_ClosePage(textpage);
UnloadPage(page);
@@ -269,14 +269,13 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) {
// Page contains two HTTP-style URLs.
EXPECT_EQ(2, FPDFLink_CountWebLinks(pagelink));
- // Only a terminating NUL required for bogus links.
- EXPECT_EQ(1, FPDFLink_GetURL(pagelink, 2, nullptr, 0));
- EXPECT_EQ(1, FPDFLink_GetURL(pagelink, 1400, nullptr, 0));
- EXPECT_EQ(1, FPDFLink_GetURL(pagelink, -1, nullptr, 0));
+ EXPECT_EQ(0, FPDFLink_GetURL(pagelink, 2, nullptr, 0));
+ EXPECT_EQ(0, FPDFLink_GetURL(pagelink, 1400, nullptr, 0));
+ EXPECT_EQ(0, FPDFLink_GetURL(pagelink, -1, nullptr, 0));
// Query the number of characters required for each link (incl NUL).
- EXPECT_EQ(25, FPDFLink_GetURL(pagelink, 0, nullptr, 0));
- EXPECT_EQ(26, FPDFLink_GetURL(pagelink, 1, nullptr, 0));
+ EXPECT_EQ(24, FPDFLink_GetURL(pagelink, 0, nullptr, 0));
+ EXPECT_EQ(25, FPDFLink_GetURL(pagelink, 1, nullptr, 0));
static const char expected_url[] = "http://example.com?q=foo";
unsigned short fixed_buffer[128];
@@ -300,21 +299,19 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) {
// Retreive link with exactly-sized buffer.
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(sizeof(expected_url),
+ EXPECT_EQ(sizeof(expected_url) - 1,
FPDFLink_GetURL(pagelink, 0, fixed_buffer, sizeof(expected_url)));
- EXPECT_TRUE(
- check_unsigned_shorts(expected_url, fixed_buffer, sizeof(expected_url)));
- EXPECT_EQ(0u, fixed_buffer[sizeof(expected_url) - 1]);
- EXPECT_EQ(0xbdbd, fixed_buffer[sizeof(expected_url)]);
+ EXPECT_TRUE(check_unsigned_shorts(expected_url, fixed_buffer,
+ sizeof(expected_url) - 1));
+ EXPECT_EQ(0xbdbd, fixed_buffer[sizeof(expected_url) - 1]);
// Retreive link with ample-sized-buffer.
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(sizeof(expected_url),
+ EXPECT_EQ(sizeof(expected_url) - 1,
FPDFLink_GetURL(pagelink, 0, fixed_buffer, 128));
- EXPECT_TRUE(
- check_unsigned_shorts(expected_url, fixed_buffer, sizeof(expected_url)));
- EXPECT_EQ(0u, fixed_buffer[sizeof(expected_url) - 1]);
- EXPECT_EQ(0xbdbd, fixed_buffer[sizeof(expected_url)]);
+ EXPECT_TRUE(check_unsigned_shorts(expected_url, fixed_buffer,
+ sizeof(expected_url) - 1));
+ EXPECT_EQ(0xbdbd, fixed_buffer[sizeof(expected_url) - 1]);
// Each link rendered in a single rect in this test page.
EXPECT_EQ(1, FPDFLink_CountRects(pagelink, 0));