File size: 1,117 Bytes
fd49381
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <string>
#include <iostream>
#include <vector>

#include "xmlrpc-c/girerr.hpp"
using girerr::error;
#include "xmlrpc-c/base64.hpp"

#include "tools.hpp"

#include "base64.hpp"

using namespace xmlrpc_c;
using namespace std;



string
base64TestSuite::suiteName() {
    return "base64TestSuite";
}



void
base64TestSuite::runtests(unsigned int const) {

    unsigned char const bytes0Data[] = "This is a test";

    vector<unsigned char> bytes0(&bytes0Data[0],
                                 &bytes0Data[sizeof(bytes0Data)]);

    string const base64_0("VGhpcyBpcyBhIHRlc3QA");

    string const expectedBase64_0(base64_0 + "\r\n");

    TEST(base64FromBytes(bytes0) == expectedBase64_0);

    TEST(bytesFromBase64(base64_0) == bytes0);

    unsigned char const bytes1Data[] = {0x80, 0xff};

    vector<unsigned char> bytes1(&bytes1Data[0],
                                 &bytes1Data[sizeof(bytes1Data)]);

    string const base64_1("gP8=");

    string const expectedBase64_1(base64_1 + "\r\n");

    TEST(base64FromBytes(bytes1) == expectedBase64_1);

    TEST(bytesFromBase64(base64_1) == bytes1);

}