add some logging
[ghsmtp.git] / Base64-test.cpp
blobeea8a59573148b74cd3940a2fb062ab002f6235c
1 #include "Base64.hpp"
3 #include <glog/logging.h>
5 int main(int argc, char* argv[])
7 auto constexpr text{R"(
8 “We are all in the gutter, but some of us are looking at the stars.”
9 ― Oscar Wilde
10 )"};
12 CHECK_EQ(Base64::dec(Base64::enc(text)), text);
14 auto s{std::string{text}};
16 CHECK_EQ(Base64::dec(Base64::enc(s)), s);
17 s.pop_back();
18 CHECK_EQ(Base64::dec(Base64::enc(s)), s);
19 s.pop_back();
20 CHECK_EQ(Base64::dec(Base64::enc(s)), s);
21 s.pop_back();
22 CHECK_EQ(Base64::dec(Base64::enc(s)), s);
24 auto constexpr empty{""};
25 CHECK_EQ(Base64::dec(Base64::enc(empty)), empty);
27 auto constexpr text_long{
28 R"(Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium ante placerat augue iaculis, consectetur commodo purus laoreet. Cras eu leo urna. Morbi sagittis nulla ut ipsum condimentum viverra. Vestibulum sed diam tortor. Maecenas consectetur scelerisque lorem, eu mollis felis tincidunt nec. Etiam ut ultricies elit. Maecenas pretium sit amet lectus sit amet semper. Sed lacinia dignissim nunc a viverra. Nunc at velit et ipsum malesuada tempor quis eu est. Aliquam egestas imperdiet purus, aliquet suscipit lectus. Nullam orci enim, egestas in felis a, sagittis egestas nulla. Nunc ultrices ultricies fringilla. Duis id tempor risus. In hac habitasse platea dictumst. Sed sit amet odio posuere, pretium sapien vel, dignissim velit.
30 Maecenas porttitor tincidunt libero, a lacinia ex pretium id. Proin venenatis non enim vel molestie. Sed finibus ornare arcu et bibendum. Vivamus est augue, facilisis sed ligula tempus, maximus pellentesque augue. Ut et sapien ac quam mattis lobortis eu eget neque. Morbi et malesuada leo, nec dignissim augue. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi congue mi sed convallis ornare. Nam euismod dolor vel risus molestie bibendum. Sed iaculis, arcu sit amet tincidunt egestas, mi risus varius lorem, eu consequat velit ex id lacus. Proin condimentum porttitor arcu, et ullamcorper mauris iaculis vitae. Nullam porta lorem sapien, interdum euismod nibh accumsan quis. Aenean varius velit vitae ipsum pulvinar laoreet. Mauris sit amet leo quis arcu pellentesque placerat.
32 Nulla id quam velit. Cras semper euismod odio rhoncus gravida. Proin at varius enim. Suspendisse in quam tincidunt, aliquam lacus in, efficitur velit. Morbi et quam enim. Praesent placerat gravida efficitur. Aenean sit amet dolor arcu. Phasellus consequat erat risus, a varius turpis posuere ultrices. Pellentesque placerat lorem eu vulputate varius. Etiam consectetur pharetra ante, eu venenatis nulla congue et.
34 Sed et bibendum neque, in elementum odio. Phasellus in lobortis tellus. Mauris condimentum mi vel metus hendrerit, a accumsan neque pellentesque. Proin feugiat dui nec sem gravida, eu tincidunt metus dignissim. Nullam magna nisi, volutpat eget luctus nec, pulvinar sit amet lacus. Donec suscipit lectus magna, fringilla euismod arcu vehicula feugiat. Ut metus orci, interdum non purus in, lobortis egestas velit. Vestibulum dui eros, tincidunt ultrices mi vitae, tincidunt varius magna. Duis commodo convallis malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque dictum tincidunt ligula et venenatis.
36 Nullam et neque eu diam blandit iaculis nec tincidunt magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc eget iaculis tellus. Curabitur pretium, nisl ut tincidunt fringilla, diam orci imperdiet purus, ut sagittis arcu sapien at felis. Cras quis enim odio. Sed sed scelerisque elit. Integer laoreet quis nulla non tristique. Aenean sed scelerisque leo. Ut et mi a lacus fermentum commodo at ut ipsum. Aliquam nunc dolor, mollis ultricies dui in, efficitur elementum magna. Suspendisse eleifend augue sapien, non accumsan mi posuere ut.)"};
38 auto constexpr text_long_enc{
39 R"(TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxp
40 dC4gUGhhc2VsbHVzIHByZXRpdW0gYW50ZSB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