mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-02 09:56:52 +08:00
lib/base: Support colons in from_hex()
This commit is contained in:
@@ -69,6 +69,13 @@ TEST(StringTests, fromhex_plaintext_string)
|
||||
EXPECT_EQ(result, std::vector<std::uint8_t>(expected.begin(), expected.end()));
|
||||
}
|
||||
|
||||
TEST(StringTests, fromhex_plaintext_string_colons)
|
||||
{
|
||||
auto result = string::from_hex("66:6f:6f:62:61:72");
|
||||
std::string expected = "foobar";
|
||||
EXPECT_EQ(result, std::vector<std::uint8_t>(expected.begin(), expected.end()));
|
||||
}
|
||||
|
||||
TEST(StringTests, fromhex_binary_string)
|
||||
{
|
||||
auto result = string::from_hex("01020304050600fff9");
|
||||
@@ -76,6 +83,13 @@ TEST(StringTests, fromhex_binary_string)
|
||||
EXPECT_EQ(result, expected);
|
||||
}
|
||||
|
||||
TEST(StringTests, fromhex_invalid_string)
|
||||
{
|
||||
EXPECT_TRUE(string::from_hex("66:6").empty());
|
||||
EXPECT_TRUE(string::from_hex("66:612").empty());
|
||||
EXPECT_TRUE(string::from_hex("66:WW").empty());
|
||||
}
|
||||
|
||||
TEST(StringTests, uppercase_lowercaseInput_uppercaseOutput)
|
||||
{
|
||||
String subject = "12foo3BaR";
|
||||
|
||||
Reference in New Issue
Block a user