1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.conv: rename functions to match other langs, making them easier t… (#18937)

This commit is contained in:
JalonSolov
2023-07-22 02:11:01 -04:00
committed by GitHub
parent bf00ac656f
commit c3ff4b2f85
4 changed files with 96 additions and 60 deletions

View File

@@ -13,32 +13,32 @@ fn check[T](f fn (a T) T, finv fn (b T) T, x T) {
}
}
fn test_htn64_nth64() {
assert 0 == conv.htn64(0)
assert 0 == conv.nth64(0)
assert 0xFFFF_FFFF_FFFF_FFFF == conv.nth64(0xFFFF_FFFF_FFFF_FFFF)
assert 0xFFFF_FFFF_FFFF_FFFF == conv.htn64(0xFFFF_FFFF_FFFF_FFFF)
fn test_hton64_ntoh64() {
assert 0 == conv.hton64(0)
assert 0 == conv.ntoh64(0)
assert 0xFFFF_FFFF_FFFF_FFFF == conv.ntoh64(0xFFFF_FFFF_FFFF_FFFF)
assert 0xFFFF_FFFF_FFFF_FFFF == conv.hton64(0xFFFF_FFFF_FFFF_FFFF)
for x in [u64(1), 2, 128, 65536, 2147483648] {
check(conv.htn64, conv.nth64, x)
check(conv.hton64, conv.ntoh64, x)
}
}
fn test_htn32_nth32() {
assert 0 == conv.htn32(0)
assert 0 == conv.nth32(0)
assert 0xFFFF_FFFF == conv.nth32(0xFFFF_FFFF)
assert 0x0101_0101 == conv.htn32(0x0101_0101)
fn test_hton32_ntoh32() {
assert 0 == conv.hton32(0)
assert 0 == conv.ntoh32(0)
assert 0xFFFF_FFFF == conv.ntoh32(0xFFFF_FFFF)
assert 0x0101_0101 == conv.hton32(0x0101_0101)
for x in [u32(1), 2, 128, 65536, 2147483648] {
check(conv.htn32, conv.nth32, x)
check(conv.hton32, conv.ntoh32, x)
}
}
fn test_htn16_nth16() {
assert 0 == conv.htn16(0)
assert 0 == conv.nth16(0)
assert 0xFFFF == conv.nth16(0xFFFF)
assert 0x0101 == conv.htn16(0x0101)
fn test_hton16_ntoh16() {
assert 0 == conv.hton16(0)
assert 0 == conv.ntoh16(0)
assert 0xFFFF == conv.ntoh16(0xFFFF)
assert 0x0101 == conv.hton16(0x0101)
for x in [u16(1), 2, 128, 65534] {
check(conv.htn16, conv.nth16, x)
check(conv.hton16, conv.ntoh16, x)
}
}