Skip to content

Commit 70b04a1

Browse files
committed
Add a test for core::str::from_cstr_len
1 parent 6408d54 commit 70b04a1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libcore/str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,14 @@ mod tests {
19791979
assert (c == "AAAAAAA");
19801980
}
19811981

1982+
#[test]
1983+
fn test_from_cstr_len() unsafe {
1984+
let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
1985+
let b = vec::to_ptr(a);
1986+
let c = from_cstr_len(b, 3u);
1987+
assert (c == "AAA");
1988+
}
1989+
19821990
#[test]
19831991
fn test_as_buf() unsafe {
19841992
let a = "Abcdefg";

0 commit comments

Comments
 (0)