Make hex_to_int and bin_to_int handle the prefix automatically
Also add BinToInt to C#
This commit is contained in:
parent
726967f453
commit
a3e3bf8227
7 changed files with 84 additions and 37 deletions
|
|
@ -370,12 +370,9 @@ TEST_CASE("[String] String to integer") {
|
|||
TEST_CASE("[String] Hex to integer") {
|
||||
static const char *nums[4] = { "0xFFAE", "22", "0", "AADDAD" };
|
||||
static const int64_t num[4] = { 0xFFAE, 0x22, 0, 0xAADDAD };
|
||||
static const bool wo_prefix[4] = { false, true, true, true };
|
||||
static const bool w_prefix[4] = { true, false, true, false };
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
CHECK((String(nums[i]).hex_to_int(true) == num[i]) == w_prefix[i]);
|
||||
CHECK((String(nums[i]).hex_to_int(false) == num[i]) == wo_prefix[i]);
|
||||
CHECK(String(nums[i]).hex_to_int() == num[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue