File: base64.cpp

package info (click to toggle)
xmlrpc-c 1.60.05-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,132 kB
  • sloc: ansic: 55,332; cpp: 13,541; sh: 3,321; makefile: 2,556; perl: 593; xml: 134
file content (54 lines) | stat: -rw-r--r-- 1,117 bytes parent folder | download | duplicates (8)
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
#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);

}