rust/tests/run-pass/strings.rs

28 lines
526 B
Rust
Raw Normal View History

2016-03-19 00:19:39 -05:00
fn empty() -> &'static str {
""
}
fn hello() -> &'static str {
"Hello, world!"
}
2016-03-19 00:20:59 -05:00
fn hello_bytes() -> &'static [u8; 13] {
b"Hello, world!"
}
2016-03-21 19:51:25 -05:00
fn hello_bytes_fat() -> &'static [u8] {
b"Hello, world!"
}
2016-04-22 03:34:14 -05:00
2016-05-31 05:05:25 -05:00
fn fat_pointer_on_32_bit() {
Some(5).expect("foo");
}
fn main() {
assert_eq!(empty(), "");
assert_eq!(hello(), "Hello, world!");
assert_eq!(hello_bytes(), b"Hello, world!");
assert_eq!(hello_bytes_fat(), b"Hello, world!");
fat_pointer_on_32_bit(); // Should run without crashing.
}