28#include "../../binary.h"
30#include "dccl/logger.h"
32int main(
int argc,
char* argv[])
35 for (
int i = 1; i < argc; ++i)
37 if (argv[i] && argv[i][0] ==
'-' && argv[i][1] ==
'v' && argv[i][2] ==
'\0')
41 dccl::dlog.
connect(verbose ? dccl::logger::ALL :
dccl::logger::WARN_PLUS, &std::cerr);
45 std::string original =
"Hello, World!";
46 std::string encoded = dccl::b64_encode(original);
47 std::string decoded = dccl::b64_decode(encoded);
48 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"original: " << original << std::endl;
49 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"encoded: " << encoded << std::endl;
50 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"decoded: " << decoded << std::endl;
51 assert(encoded ==
"SGVsbG8sIFdvcmxkIQ==");
52 assert(decoded == original);
57 std::string binary_data(
"\x00\x01\x02\x03\xff\xfe\xfd", 7);
58 std::string encoded = dccl::b64_encode(binary_data);
59 std::string decoded = dccl::b64_decode(encoded);
60 assert(decoded == binary_data);
66 std::string encoded = dccl::b64_encode(empty);
67 std::string decoded = dccl::b64_decode(encoded);
68 assert(encoded.empty());
69 assert(decoded.empty());
74 assert(dccl::b64_encode(
"Man") ==
"TWFu");
75 assert(dccl::b64_encode(
"Ma") ==
"TWE=");
76 assert(dccl::b64_encode(
"M") ==
"TQ==");
77 assert(dccl::b64_decode(
"TWFu") ==
"Man");
78 assert(dccl::b64_decode(
"TWE=") ==
"Ma");
79 assert(dccl::b64_decode(
"TQ==") ==
"M");
84 std::string long_data(1000,
'\0');
85 std::iota(long_data.begin(), long_data.end(), 0);
86 std::string encoded = dccl::b64_encode(long_data);
87 std::string decoded = dccl::b64_decode(encoded);
89 assert(encoded.size() % 4 == 0);
90 assert(decoded == long_data);
93 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"all tests passed" << std::endl;
bool is(logger::Verbosity verbosity, logger::Group group=logger::GENERAL)
Indicates the verbosity of the Logger until the next std::flush or std::endl. The boolean return is u...
void connect(int verbosity_mask, Slot slot)
Connect the output of one or more given verbosities to a slot (function pointer or similar)
Dynamic Compact Control Language namespace.