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

builtin: add charptr.vstring() and charptr.vstring_with_len() (#6830)

This commit is contained in:
Swastik Baranwal
2020-11-14 23:13:42 +05:30
committed by GitHub
parent 827fb62c29
commit 00464ad988
2 changed files with 26 additions and 0 deletions

View File

@ -528,6 +528,14 @@ fn test_bytes_to_string() {
assert bytes.bytestr() == 'hello'
}
fn test_charptr() {
foo := charptr('VLANG'.str)
println(typeof(foo))
assert typeof(foo) == 'charptr'
assert unsafe { foo.vstring() } == 'VLANG'
assert unsafe { foo.vstring_with_len(3) } == 'VLA'
}
fn test_count() {
assert ''.count('') == 0
assert ''.count('a') == 0