mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-01-01 03:12:18 +08:00
lint
Signed-off-by: Shikhar <shikharish05@gmail.com>
This commit is contained in:
parent
e076a81b2d
commit
97cb3ec28d
@ -21,12 +21,9 @@ char* uint8_to_chars_manual(char* ptr, uint8_t value) {
|
||||
}
|
||||
|
||||
void uint32_to_ipv4_string(uint32_t ip, char *buffer) {
|
||||
uint8_t octets[4] = {
|
||||
static_cast<uint8_t>(ip >> 24),
|
||||
uint8_t octets[4] = {static_cast<uint8_t>(ip >> 24),
|
||||
static_cast<uint8_t>(ip >> 16),
|
||||
static_cast<uint8_t>(ip >> 8),
|
||||
static_cast<uint8_t>(ip)
|
||||
};
|
||||
static_cast<uint8_t>(ip >> 8), static_cast<uint8_t>(ip)};
|
||||
|
||||
char *ptr = buffer;
|
||||
|
||||
@ -40,7 +37,8 @@ void uint32_to_ipv4_string(uint32_t ip, char* buffer) {
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
fastfloat_really_inline uint32_t ipv4_string_to_uint32(const char* str, const char* end) {
|
||||
fastfloat_really_inline uint32_t ipv4_string_to_uint32(const char *str,
|
||||
const char *end) {
|
||||
uint32_t ip = 0;
|
||||
const char *current = str;
|
||||
|
||||
@ -63,7 +61,9 @@ fastfloat_really_inline uint32_t ipv4_string_to_uint32(const char* str, const ch
|
||||
}
|
||||
|
||||
bool test_all_ipv4_conversions() {
|
||||
std::cout << "Testing all IPv4 conversions... 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, ..." << std::endl;
|
||||
std::cout << "Testing all IPv4 conversions... 0, 1000, 2000, 3000, 4000, "
|
||||
"5000, 6000, 7000, 8000, 9000, ..."
|
||||
<< std::endl;
|
||||
char buffer[16];
|
||||
for (uint64_t ip = 0; ip <= 0xFFFFFFFF; ip += 1000) {
|
||||
if (ip % 10000000 == 0) {
|
||||
@ -73,7 +73,8 @@ bool test_all_ipv4_conversions() {
|
||||
const char *end = buffer + strlen(buffer);
|
||||
uint32_t parsed_ip = ipv4_string_to_uint32(buffer, end);
|
||||
if (parsed_ip != ip) {
|
||||
std::cerr << "Mismatch: original " << ip << ", parsed " << parsed_ip << std::endl;
|
||||
std::cerr << "Mismatch: original " << ip << ", parsed " << parsed_ip
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user