summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdftext_embeddertest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-05 10:17:30 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-05 10:17:30 -0800
commit8ab45eafebfd510554920e09e5ee85e94701dea9 (patch)
tree5395b97d113552edc0c4c6bf3142302441da666e /fpdfsdk/src/fpdftext_embeddertest.cpp
parent0861c161376074bce453de31fdf96e120c482696 (diff)
downloadpdfium-8ab45eafebfd510554920e09e5ee85e94701dea9.tar.xz
Merge to XFA: Make FPDF_WIDESTRING work regardless of endianness.
Original Review URL: https://codereview.chromium.org/1554363002 . (cherry picked from commit ed34cdf99d5a4b33e57f81f9244a311f6fb86db3) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1559373002 .
Diffstat (limited to 'fpdfsdk/src/fpdftext_embeddertest.cpp')
-rw-r--r--fpdfsdk/src/fpdftext_embeddertest.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/fpdfsdk/src/fpdftext_embeddertest.cpp b/fpdfsdk/src/fpdftext_embeddertest.cpp
index 6c1ae4ceb8..3772686c88 100644
--- a/fpdfsdk/src/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/src/fpdftext_embeddertest.cpp
@@ -5,6 +5,7 @@
#include "public/fpdf_text.h"
#include "public/fpdfview.h"
#include "testing/embedder_test.h"
+#include "testing/test_support.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -143,11 +144,10 @@ TEST_F(FPDFTextEmbeddertest, TextSearch) {
FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page);
EXPECT_NE(nullptr, textpage);
- // Avoid issues with system wchar_t width vs. FPDF_WideString.
- const unsigned short nope[] = {'n', 'o', 'p', 'e', '\0'};
- const unsigned short world[] = {'w', 'o', 'r', 'l', 'd', '\0'};
- const unsigned short world_caps[] = {'W', 'O', 'R', 'L', 'D', '\0'};
- const unsigned short world_substr[] = {'o', 'r', 'l', 'd', '\0'};
+ FPDF_WIDESTRING nope = GetFPDFWideString(L"nope");
+ FPDF_WIDESTRING world = GetFPDFWideString(L"world");
+ FPDF_WIDESTRING world_caps = GetFPDFWideString(L"WORLD");
+ FPDF_WIDESTRING world_substr = GetFPDFWideString(L"orld");
// No occurences of "nope" in test page.
FPDF_SCHHANDLE search = FPDFText_FindStart(textpage, nope, 0, 0);
@@ -239,6 +239,12 @@ TEST_F(FPDFTextEmbeddertest, TextSearch) {
FPDFText_ClosePage(textpage);
UnloadPage(page);
+
+ // Alas, the typedef includes the "const".
+ free(const_cast<unsigned short*>(nope));
+ free(const_cast<unsigned short*>(world));
+ free(const_cast<unsigned short*>(world_caps));
+ free(const_cast<unsigned short*>(world_substr));
}
// Test that the page has characters despite a bad stream length.