summaryrefslogtreecommitdiff
path: root/testing/test_support.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-04-28 16:54:10 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-02 18:57:50 +0000
commitd9e0e6e46d1f24231b8ab3def4cc197554e96fe7 (patch)
tree811766e948d4946c9db77a1f4bc8816daf3c03bb /testing/test_support.cpp
parentb31618571938e4873dcf1cdd44eeedb40caa5bd7 (diff)
downloadpdfium-d9e0e6e46d1f24231b8ab3def4cc197554e96fe7.tar.xz
Change BarcodeTest to render to bitmaps.
BarcodeTest renders to bitmaps verifies their checksums. Add some commonly used checksumming code to testing/test_support.h, and use it in tests that have duplicate code. Change-Id: I4a440674ff1084685b5d89576d967333da458a8a Reviewed-on: https://pdfium-review.googlesource.com/4618 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'testing/test_support.cpp')
-rw-r--r--testing/test_support.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/test_support.cpp b/testing/test_support.cpp
index a2e9a6a6dd..608e4ae75b 100644
--- a/testing/test_support.cpp
+++ b/testing/test_support.cpp
@@ -150,6 +150,24 @@ std::unique_ptr<unsigned short, pdfium::FreeDeleter> GetFPDFWideString(
return result;
}
+std::string CryptToBase16(const uint8_t* digest) {
+ static char const zEncode[] = "0123456789abcdef";
+ std::string ret;
+ ret.resize(32);
+ for (int i = 0, j = 0; i < 16; i++, j += 2) {
+ uint8_t a = digest[i];
+ ret[j] = zEncode[(a >> 4) & 0xf];
+ ret[j + 1] = zEncode[a & 0xf];
+ }
+ return ret;
+}
+
+std::string GenerateMD5Base16(const uint8_t* data, uint32_t size) {
+ uint8_t digest[16];
+ CRYPT_MD5Generate(data, size, digest);
+ return CryptToBase16(digest);
+}
+
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
bool InitializeV8ForPDFium(const std::string& exe_path,