diff options
| author | Jeffrey Yasskin <[email protected]> | 2010-07-25 00:36:03 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-08-06 17:29:21 -0700 |
| commit | 3f6e8ffe64b57b0eaba6812208e94500422ca40c (patch) | |
| tree | bb6ed1f9b5ce9603c999c195d0754057e633599a /src/test | |
| parent | Add an int->str conversion function. (diff) | |
| download | rust-3f6e8ffe64b57b0eaba6812208e94500422ca40c.tar.xz rust-3f6e8ffe64b57b0eaba6812208e94500422ca40c.zip | |
Implement _str.len() to return the number of bytes, rename it to byte_len(),
and add a test.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/str-lib.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/run-pass/str-lib.rs b/src/test/run-pass/str-lib.rs new file mode 100644 index 00000000..585f9b8d --- /dev/null +++ b/src/test/run-pass/str-lib.rs @@ -0,0 +1,16 @@ +use std; +import std._str; + +fn test_bytes_len() { + check (_str.byte_len("") == 0u); + check (_str.byte_len("hello world") == 11u); + check (_str.byte_len("\x63") == 1u); + check (_str.byte_len("\xa2") == 2u); + check (_str.byte_len("\u03c0") == 2u); + check (_str.byte_len("\u2620") == 3u); + check (_str.byte_len("\U0001d11e") == 4u); +} + +fn main() { + test_bytes_len(); +} |