summaryrefslogtreecommitdiff
path: root/core
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 /core
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 'core')
-rw-r--r--core/fdrm/crypto/fx_crypt_unittest.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/core/fdrm/crypto/fx_crypt_unittest.cpp b/core/fdrm/crypto/fx_crypt_unittest.cpp
index 4e3da6e186..f5fb457d3d 100644
--- a/core/fdrm/crypto/fx_crypt_unittest.cpp
+++ b/core/fdrm/crypto/fx_crypt_unittest.cpp
@@ -11,34 +11,21 @@
#include "core/fxcrt/fx_basic.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/test_support.h"
namespace {
-std::string CRYPT_ToBase16(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 CRYPT_MD5String(const char* str) {
- uint8_t digest[16];
- CRYPT_MD5Generate(reinterpret_cast<const uint8_t*>(str), strlen(str), digest);
- return CRYPT_ToBase16(digest);
+ return GenerateMD5Base16(reinterpret_cast<const uint8_t*>(str), strlen(str));
}
} // namespace
-TEST(FXCRYPT, CRYPT_ToBase16) {
+TEST(FXCRYPT, CryptToBase16) {
uint8_t data[] = {0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e};
- std::string actual = CRYPT_ToBase16(data);
+ std::string actual = CryptToBase16(data);
std::string expected = "d41d8cd98f00b204e9800998ecf8427e";
EXPECT_EQ(expected, actual);
@@ -194,7 +181,7 @@ TEST(FXCRYPT, ContextWithStringData) {
uint8_t digest[16];
CRYPT_MD5Finish(&ctx, digest);
- std::string actual = CRYPT_ToBase16(digest);
+ std::string actual = CryptToBase16(digest);
std::string expected = "900150983cd24fb0d6963f7d28e17f72";
EXPECT_EQ(expected, actual);
}