forked from aranetic/process-pst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilities_spec.cpp
More file actions
76 lines (62 loc) · 2.61 KB
/
utilities_spec.cpp
File metadata and controls
76 lines (62 loc) · 2.61 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
//
// process-pst: Convert PST files to RCF822 *.eml files and load files
// Copyright (c) 2010 Aranetic LLC
// Look for the latest version at http://github.com/aranetic/process-pst
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU Affero General Public License (the "License")
// as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but it
// is provided on an "AS-IS" basis and WITHOUT ANY WARRANTY; without even
// the implied warranties of MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE, OR NONINFRINGEMENT. See the GNU Affero General Public License
// for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <cassert>
#include "utilities.h"
using namespace std;
void string_to_wstring_should_convert_native_8_bit_to_unicode() {
assert(L"" == string_to_wstring(""));
assert(L"text" == string_to_wstring("text"));
}
void wstring_to_string_should_convert_unicode_to_native_8_bit() {
assert("" == wstring_to_string(L""));
assert("text" == wstring_to_string(L"text"));
}
void wstring_to_utf8_should_convert_to_utf8() {
assert("" == wstring_to_utf8(L""));
assert("text" == wstring_to_utf8(L"text"));
assert(0x2014 == wstring(L"\u2014")[0]);
assert("\xE2\x80\x94" == wstring_to_utf8(L"\u2014")); // em-dash
}
void bytes_to_hex_string_should_convert_vector_to_hex() {
vector<uint8_t> v;
v.push_back(0);
v.push_back(255);
assert("00ff" == bytes_to_hex_string(v));
}
void md5_should_calculate_md5_hash_for_vector() {
string s("Data");
vector<uint8_t> v(s.begin(), s.end());
assert("f6068daa29dbb05a7ead1e3b5a48bbee" == md5(v));
}
void xml_quote_should_convert_wstring_and_escape_metacharacters() {
assert("" == xml_quote(L""));
assert("test" == xml_quote(L"test"));
assert("\xE2\x80\x94" == xml_quote(L"\u2014"));
assert("<&"'>" == xml_quote(L"<&\"'>"));
}
int utilities_spec(int argc, char **argv) {
string_to_wstring_should_convert_native_8_bit_to_unicode();
wstring_to_string_should_convert_unicode_to_native_8_bit();
wstring_to_utf8_should_convert_to_utf8();
bytes_to_hex_string_should_convert_vector_to_hex();
md5_should_calculate_md5_hash_for_vector();
xml_quote_should_convert_wstring_and_escape_metacharacters();
return 0;
}