Make hex_to_int and bin_to_int handle the prefix automatically

Also add BinToInt to C#
This commit is contained in:
Aaron Franke 2021-01-28 07:39:05 -05:00
parent 726967f453
commit a3e3bf8227
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
7 changed files with 84 additions and 37 deletions

View file

@ -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]);
}
}