-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (27 loc) · 789 Bytes
/
Copy pathmain.cpp
File metadata and controls
37 lines (27 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "base64.hpp"
#include <iomanip>
#include <iostream>
#include <iterator>
void test(const std::string& what, const std::string& expected)
{
auto actual = base64::encode(what);
std::cout << "base64(\"" << what << "\") = " << expected << ": " << (actual == expected) << " | "
<< (base64::decode(actual) == what) << '\n';
}
int main()
{
std::cout << std::boolalpha;
/*auto b = "f";
auto e = b + 1;
base64::encode(b, e, std::ostream_iterator<char>(std::cout));*/
std::string str = "Zm9=";
base64::decode(str.begin(), str.end(), std::ostream_iterator<char>(std::cout));
std::cout << std::endl;
test("", "");
test("f", "Zg==");
test("fo", "Zm8=");
test("foo", "Zm9v");
test("foob", "Zm9vYg==");
test("fooba", "Zm9vYmE=");
test("foobar", "Zm9vYmFy");
}