9
9
10
10
#include < boost/config.hpp>
11
11
#include < boost/algorithm/hex.hpp>
12
+ #include < boost/algorithm/string/case_conv.hpp>
12
13
13
14
#define BOOST_TEST_MAIN
14
15
#include < boost/test/unit_test.hpp>
@@ -42,6 +43,31 @@ void test_to_hex ( const typename String::value_type ** tests ) {
42
43
}
43
44
}
44
45
46
+ template <typename String>
47
+ void test_to_hex_lower ( const typename String::value_type ** tests ) {
48
+ for ( const typename String::value_type **p = tests; *p; p++ ) {
49
+ String arg, argh, one, two, three, four;
50
+ arg.assign ( *p );
51
+ boost::algorithm::hex_lower ( *p, std::back_inserter ( one ));
52
+ boost::algorithm::hex_lower ( arg, std::back_inserter ( two ));
53
+ boost::algorithm::hex_lower ( arg.begin (), arg.end (), std::back_inserter ( three ));
54
+ four = boost::algorithm::hex_lower ( arg );
55
+ BOOST_CHECK ( one == two );
56
+ BOOST_CHECK ( one == three );
57
+ BOOST_CHECK ( one == four );
58
+ argh = one;
59
+ one.clear (); two.clear (); three.clear (); four.clear ();
60
+ boost::algorithm::unhex ( argh.c_str (), std::back_inserter ( one ));
61
+ boost::algorithm::unhex ( argh, std::back_inserter ( two ));
62
+ boost::algorithm::unhex ( argh.begin (), argh.end (), std::back_inserter ( three ));
63
+ four = boost::algorithm::unhex ( argh );
64
+ BOOST_CHECK ( one == two );
65
+ BOOST_CHECK ( one == three );
66
+ BOOST_CHECK ( one == four );
67
+ BOOST_CHECK ( one == arg );
68
+ }
69
+ }
70
+
45
71
46
72
template <typename String>
47
73
void test_from_hex_success ( const typename String::value_type ** tests ) {
@@ -61,6 +87,11 @@ void test_from_hex_success ( const typename String::value_type ** tests ) {
61
87
boost::algorithm::hex ( argh, std::back_inserter ( two ));
62
88
boost::algorithm::hex ( argh.begin (), argh.end (), std::back_inserter ( three ));
63
89
four = boost::algorithm::hex ( argh );
90
+ boost::algorithm::to_lower ( arg );
91
+ boost::algorithm::to_lower ( one );
92
+ boost::algorithm::to_lower ( two );
93
+ boost::algorithm::to_lower ( three );
94
+ boost::algorithm::to_lower ( four );
64
95
BOOST_CHECK ( one == two );
65
96
BOOST_CHECK ( one == three );
66
97
BOOST_CHECK ( one == four );
@@ -113,13 +144,15 @@ const wchar_t *tohex_w [] = {
113
144
const char *fromhex [] = {
114
145
" 20" ,
115
146
" 2122234556FF" ,
147
+ " 2122234556ff" ,
116
148
NULL // End of the list
117
149
};
118
150
119
151
120
152
const wchar_t *fromhex_w [] = {
121
153
L" 00101020" ,
122
154
L" 2122234556FF3456" ,
155
+ L" 2122234556ff3456" ,
123
156
NULL // End of the list
124
157
};
125
158
@@ -129,6 +162,8 @@ const char *fromhex_fail [] = {
129
162
" H" ,
130
163
" 234" ,
131
164
" 21222G4556FF" ,
165
+ " h" ,
166
+ " 21222g4556ff" ,
132
167
NULL // End of the list
133
168
};
134
169
@@ -139,17 +174,21 @@ const wchar_t *fromhex_fail_w [] = {
139
174
L" H" ,
140
175
L" 234" ,
141
176
L" 21222G4556FF" ,
177
+ L" h" ,
178
+ L" 21222g4556ff" ,
142
179
NULL // End of the list
143
180
};
144
181
145
182
146
183
BOOST_AUTO_TEST_CASE ( test_main )
147
184
{
148
185
test_to_hex<std::string> ( tohex );
186
+ test_to_hex_lower<std::string> ( tohex );
149
187
test_from_hex_success<std::string> ( fromhex );
150
188
test_from_hex_failure<std::string> ( fromhex_fail );
151
189
152
190
test_to_hex<std::wstring> ( tohex_w );
191
+ test_to_hex_lower<std::wstring> ( tohex_w );
153
192
test_from_hex_success<std::wstring> ( fromhex_w );
154
193
test_from_hex_failure<std::wstring> ( fromhex_fail_w );
155
194
}
0 commit comments