File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -3032,6 +3032,29 @@ mod tests {
3032
3032
assert_eq!(s.to_c_str(), v);
3033
3033
}
3034
3034
3035
+ #[test]
3036
+ fn test_as_c_str() {
3037
+ let a = ~" ";
3038
+ do a.as_c_str |buf| {
3039
+ unsafe {
3040
+ assert_eq!(*ptr::offset(buf, 0), 0);
3041
+ }
3042
+ }
3043
+
3044
+ let a = ~" hello";
3045
+ do a.as_c_str |buf| {
3046
+ unsafe {
3047
+ assert_eq!(*ptr::offset(buf, 0), 'h' as libc::c_char);
3048
+ assert_eq!(*ptr::offset(buf, 1), 'e' as libc::c_char);
3049
+ assert_eq!(*ptr::offset(buf, 2), 'l' as libc::c_char);
3050
+ assert_eq!(*ptr::offset(buf, 3), 'l' as libc::c_char);
3051
+ assert_eq!(*ptr::offset(buf, 4), 'o' as libc::c_char);
3052
+ assert_eq!(*ptr::offset(buf, 5), 0);
3053
+ }
3054
+ }
3055
+ }
3056
+
3057
+ #[test]
3035
3058
fn test_subslice_offset() {
3036
3059
let a = " kernelsprite";
3037
3060
let b = a.slice(7, a.len());
You can’t perform that action at this time.
0 commit comments