1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
Files
v/vlib/v/tests/cstrings_test.v
2020-08-10 18:05:26 +02:00

17 lines
395 B
V

fn test_cstring() {
w := c'world'
hlen := unsafe{ C.strlen(c'hello') }
hlen2 := unsafe{ C.strlen('hello') }
wlen := unsafe{ C.strlen(w) }
assert hlen == 5
assert hlen2 == 5
assert wlen == 5
}
fn test_cstring_with_zeros() {
rawbytes := c'\x00username\x00password'
s := unsafe { rawbytes.vstring_with_len(18) }
h := s.bytes().hex()
assert h == '00757365726e616d650070617373776f7264'
}