mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
builtin.string: new fn (s string) is_ascii() bool (#14418)
This commit is contained in:
parent
d10f83ce15
commit
02c8a6057c
2 changed files with 15 additions and 0 deletions
|
@ -989,6 +989,16 @@ fn test_string_f32() {
|
|||
assert '-123.456'.f32() - (-123.456) <= f32_epsilon
|
||||
}
|
||||
|
||||
fn test_string_is_ascii() {
|
||||
assert ''.is_ascii() == true
|
||||
assert ' '.is_ascii() == true
|
||||
assert '~~'.is_ascii() == true
|
||||
assert ' Az~'.is_ascii() == true
|
||||
assert ' Aö~'.is_ascii() == false
|
||||
assert '👋'.is_ascii() == false
|
||||
assert 'a👋bc'.is_ascii() == false
|
||||
}
|
||||
|
||||
fn test_string_with_zero_byte_escape() {
|
||||
assert '\x00'.bytes() == [u8(0)]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue