proxygen
Base64Test.cpp File Reference

Go to the source code of this file.

Functions

 TEST (Base64, BasicEncode)
 
 TEST (Base64, BasicDecode)
 
 TEST (Base64, Encode)
 
 TEST (Base64, EncodeDecodeNL)
 
 TEST (Base64, Decode)
 
 TEST (Base64, DecodeEmpty)
 
 TEST (Base64, DecodeGarbage)
 
 TEST (Base64, DecodePadding)
 
 TEST (Base64, EncodeDecodeHighBits)
 

Function Documentation

TEST ( Base64  ,
BasicEncode   
)

Definition at line 24 of file Base64Test.cpp.

References encode(), EXPECT_EQ, and folly::gen::range().

24  {
25  EXPECT_EQ(Base64::encode(range("a")), "YQ==");
26  EXPECT_EQ(Base64::encode(range("ab")), "YWI=");
27  EXPECT_EQ(Base64::encode(range("abc")), "YWJj");
28 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Gen range(Value begin, Value end)
Definition: Base.h:467
TEST ( Base64  ,
BasicDecode   
)

Definition at line 30 of file Base64Test.cpp.

References fizz::decode(), and EXPECT_EQ.

30  {
31  EXPECT_EQ(Base64::decode("YQ==", 2), "a");
32  EXPECT_EQ(Base64::decode("YWI=", 1), "ab");
33  EXPECT_EQ(Base64::decode("YWJj", 0), "abc");
34 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TokenBindingMessage decode(folly::io::Cursor &cursor)
Definition: Types.cpp:132
TEST ( Base64  ,
Encode   
)

Definition at line 36 of file Base64Test.cpp.

References EXPECT_EQ, and folly::gen::range().

36  {
37  EXPECT_EQ(Base64::urlEncode(range("hello world")), "aGVsbG8gd29ybGQ");
38 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Gen range(Value begin, Value end)
Definition: Base.h:467
TEST ( Base64  ,
EncodeDecodeNL   
)

Definition at line 40 of file Base64Test.cpp.

References EXPECT_EQ, and folly::gen::range().

40  {
41  EXPECT_EQ(Base64::urlEncode(range("hello \nworld")), "aGVsbG8gCndvcmxk");
42  EXPECT_EQ(Base64::urlDecode("aGVsbG8gCndvcmxk"), "hello \nworld");
43 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Gen range(Value begin, Value end)
Definition: Base.h:467
TEST ( Base64  ,
Decode   
)

Definition at line 45 of file Base64Test.cpp.

References EXPECT_EQ.

45  {
46  EXPECT_EQ(Base64::urlDecode("aGVsbG8gd29ybGQ"), "hello world");
47 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( Base64  ,
DecodeEmpty   
)

Definition at line 49 of file Base64Test.cpp.

References EXPECT_EQ.

49  {
50  EXPECT_EQ(Base64::urlDecode(""), "");
51 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( Base64  ,
DecodeGarbage   
)

Definition at line 53 of file Base64Test.cpp.

References EXPECT_EQ.

53  {
54  EXPECT_EQ(Base64::urlDecode("[[[[["), "");
55 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( Base64  ,
DecodePadding   
)

Definition at line 57 of file Base64Test.cpp.

References EXPECT_EQ.

57  {
58  EXPECT_EQ(Base64::urlDecode("YQ"), "a");
59  EXPECT_EQ(Base64::urlDecode("YWE"), "aa");
60  EXPECT_EQ(Base64::urlDecode("YWFh"), "aaa");
61 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( Base64  ,
EncodeDecodeHighBits   
)

Definition at line 63 of file Base64Test.cpp.

References EXPECT_EQ, folly::gen::range(), and string.

63  {
64  EXPECT_EQ(Base64::urlDecode("_--_"), std::string("\xff\xef\xbf", 3));
65  EXPECT_EQ(Base64::urlEncode(range("\xff\xef\xbf", 3)), "_--_");
66 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Gen range(Value begin, Value end)
Definition: Base.h:467
const char * string
Definition: Conv.cpp:212