| 1 | fn test_cstring() { |
| 2 | w := &char(c'world') |
| 3 | hlen := unsafe { C.strlen(c'hello') } |
| 4 | wlen := unsafe { C.strlen(w) } |
| 5 | assert hlen == 5 |
| 6 | assert wlen == 5 |
| 7 | } |
| 8 | |
| 9 | fn test_cstring_with_zeros() { |
| 10 | rawbytes := &char(c'\x00username\x00password') |
| 11 | s := unsafe { rawbytes.vstring_with_len(18) } |
| 12 | assert s.hex() == '00757365726e616d650070617373776f7264' |
| 13 | } |
| 14 |