builtin.string: new fn (s string) is_ascii() bool (#14418)

This commit is contained in:
WoodyAtHome 2022-05-17 07:01:03 +02:00 committed by GitHub
parent d10f83ce15
commit 02c8a6057c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -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)]
}