summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdftext_embeddertest.cpp
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-03-29 16:42:53 -0700
committerWei Li <weili@chromium.org>2016-03-29 16:42:53 -0700
commit05d53f0355e9889c43bfa436e985d5643f249d99 (patch)
treeeca037b407114efe357e8280a96e44eee182cdfc /fpdfsdk/fpdftext_embeddertest.cpp
parent602aebc11a615971800d38f8d427a4e4f95c1134 (diff)
downloadpdfium-05d53f0355e9889c43bfa436e985d5643f249d99.tar.xz
Code change to avoid signed/unsigned mismatch warnings.
This makes pdfium code on Linux and Mac sign-compare warning free. The warning flag will be re-enabled after checking on windows clang build. BUG=pdfium:29 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1841643002 .
Diffstat (limited to 'fpdfsdk/fpdftext_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdftext_embeddertest.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/fpdfsdk/fpdftext_embeddertest.cpp b/fpdfsdk/fpdftext_embeddertest.cpp
index ed20882a1b..a5215c20cc 100644
--- a/fpdfsdk/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/fpdftext_embeddertest.cpp
@@ -48,7 +48,8 @@ TEST_F(FPDFTextEmbeddertest, Text) {
EXPECT_TRUE(check_unsigned_shorts(expected, fixed_buffer, sizeof(expected)));
// Count does not include the terminating NUL in the string literal.
- EXPECT_EQ(sizeof(expected) - 1, FPDFText_CountChars(textpage));
+ EXPECT_EQ(sizeof(expected) - 1,
+ static_cast<size_t>(FPDFText_CountChars(textpage)));
for (size_t i = 0; i < sizeof(expected) - 1; ++i) {
EXPECT_EQ(static_cast<unsigned int>(expected[i]),
FPDFText_GetUnicode(textpage, i))
@@ -285,6 +286,7 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) {
EXPECT_EQ(26, FPDFLink_GetURL(pagelink, 1, nullptr, 0));
static const char expected_url[] = "http://example.com?q=foo";
+ static const size_t expected_len = sizeof(expected_url);
unsigned short fixed_buffer[128];
// Retrieve a link with too small a buffer. Buffer will not be
@@ -297,30 +299,27 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) {
// Check buffer that doesn't have space for a terminating NUL.
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(
- sizeof(expected_url) - 1,
- FPDFLink_GetURL(pagelink, 0, fixed_buffer, sizeof(expected_url) - 1));
- EXPECT_TRUE(check_unsigned_shorts(expected_url, fixed_buffer,
- sizeof(expected_url) - 1));
- EXPECT_EQ(0xbdbd, fixed_buffer[sizeof(expected_url) - 1]);
+ EXPECT_EQ(static_cast<int>(expected_len - 1),
+ FPDFLink_GetURL(pagelink, 0, fixed_buffer, expected_len - 1));
+ EXPECT_TRUE(
+ check_unsigned_shorts(expected_url, fixed_buffer, expected_len - 1));
+ EXPECT_EQ(0xbdbd, fixed_buffer[expected_len - 1]);
// Retreive link with exactly-sized buffer.
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(sizeof(expected_url),
- 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_EQ(static_cast<int>(expected_len),
+ FPDFLink_GetURL(pagelink, 0, fixed_buffer, expected_len));
+ EXPECT_TRUE(check_unsigned_shorts(expected_url, fixed_buffer, expected_len));
+ EXPECT_EQ(0u, fixed_buffer[expected_len - 1]);
+ EXPECT_EQ(0xbdbd, fixed_buffer[expected_len]);
// Retreive link with ample-sized-buffer.
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(sizeof(expected_url),
+ EXPECT_EQ(static_cast<int>(expected_len),
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, expected_len));
+ EXPECT_EQ(0u, fixed_buffer[expected_len - 1]);
+ EXPECT_EQ(0xbdbd, fixed_buffer[expected_len]);
// Each link rendered in a single rect in this test page.
EXPECT_EQ(1, FPDFLink_CountRects(pagelink, 0));
@@ -382,7 +381,7 @@ TEST_F(FPDFTextEmbeddertest, GetFontSize) {
16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
int count = FPDFText_CountChars(textpage);
- ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), count);
+ ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), static_cast<size_t>(count));
for (int i = 0; i < count; ++i)
EXPECT_EQ(kExpectedFontsSizes[i], FPDFText_GetFontSize(textpage, i)) << i;