proxygen
CryptUtilTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
12 #include <string>
13 
14 using namespace proxygen;
15 
16 using folly::ByteRange;
17 
18 TEST(CryptUtilTest, Base64EncodeTest) {
19  ASSERT_EQ("",
21  ByteRange(
22  reinterpret_cast<const unsigned char*>(""), (size_t) 0)));
23  ASSERT_EQ("YQ==",
25  ByteRange(
26  reinterpret_cast<const unsigned char*>("a"), 1)));
27  ASSERT_EQ("YWE=",
29  ByteRange(
30  reinterpret_cast<const unsigned char*>("aa"), 2)));
31  ASSERT_EQ("QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
33  ByteRange(
34  reinterpret_cast<const unsigned char*>("Aladdin:open sesame"), 19)));
35 }
36 
37 TEST(CryptUtilTest, MD5EncodeTest) {
38  ASSERT_EQ("d41d8cd98f00b204e9800998ecf8427e",
39  md5Encode(
40  ByteRange(
41  reinterpret_cast<const unsigned char*>(""),
42  (size_t) 0)));
43  ASSERT_EQ("a7a93b8ac14a48faa68e4afb57b00fc7",
44  md5Encode(
45  ByteRange(
46  reinterpret_cast<const unsigned char*>("Aladdin:open sesame"),
47  19)));
48 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
TEST(CryptUtilTest, Base64EncodeTest)
std::string base64Encode(folly::ByteRange text)
Definition: CryptUtil.cpp:21
std::string md5Encode(folly::ByteRange text)
Definition: CryptUtil.cpp:60
Range< const unsigned char * > ByteRange
Definition: Range.h:1163