File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,18 @@ BOOST_AUTO_TEST_CASE(parse_hex)
149
149
result = ParseHex (" 89 34 56 78" );
150
150
BOOST_CHECK (result.size () == 4 && result[0 ] == 0x89 && result[1 ] == 0x34 && result[2 ] == 0x56 && result[3 ] == 0x78 );
151
151
152
+ // Mixed case and spaces are supported
153
+ result = ParseHex (" Ff aA " );
154
+ BOOST_CHECK (result.size () == 2 && result[0 ] == 0xff && result[1 ] == 0xaa );
155
+
156
+ // Empty string is supported
157
+ result = ParseHex (" " );
158
+ BOOST_CHECK (result.size () == 0 );
159
+
160
+ // Spaces between nibbles is treated as end
161
+ result = ParseHex (" AAF F" );
162
+ BOOST_CHECK (result.size () == 1 && result[0 ] == 0xaa );
163
+
152
164
// Embedded null is treated as end
153
165
const std::string with_embedded_null{" 11 " s
154
166
" \0 "
@@ -160,6 +172,10 @@ BOOST_AUTO_TEST_CASE(parse_hex)
160
172
// Stop parsing at invalid value
161
173
result = ParseHex (" 1234 invalid 1234" );
162
174
BOOST_CHECK (result.size () == 2 && result[0 ] == 0x12 && result[1 ] == 0x34 );
175
+
176
+ // Truncated input is treated as end
177
+ result = ParseHex (" 12 3" );
178
+ BOOST_CHECK (result.size () == 1 && result[0 ] == 0x12 );
163
179
}
164
180
165
181
BOOST_AUTO_TEST_CASE (util_HexStr)
You can’t perform that action at this time.
0 commit comments