提交 b98255cb 编写于 作者: V Vadim Petrochenkov

Add and fix more tests

上级 1e9bef91
......@@ -448,7 +448,8 @@ pub fn as_mut_slice(&mut self) -> &mut [T] {
/// ```
/// use std::old_io::IoResult;
///
/// let mut buffer = &mut b"1\n2\n3\n4\n";
/// let mut buffer: &[u8] = b"1\n2\n3\n4\n";
/// let mut buffer = &mut buffer;
///
/// let mut sum = 0;
///
......
......@@ -311,7 +311,7 @@ fn dirname_str<'a>(&'a self) -> Option<&'a str> {
/// # #[cfg(windows)] fn foo() {}
/// # #[cfg(unix)] fn foo() {
/// let p = Path::new("abc/def/ghi");
/// assert_eq!(p.filename(), Some(b"ghi"));
/// assert_eq!(p.filename(), Some(&b"ghi"[..]));
/// # }
/// ```
fn filename<'a>(&'a self) -> Option<&'a [u8]>;
......@@ -345,7 +345,7 @@ fn filename_str<'a>(&'a self) -> Option<&'a str> {
/// # #[cfg(windows)] fn foo() {}
/// # #[cfg(unix)] fn foo() {
/// let p = Path::new("/abc/def.txt");
/// assert_eq!(p.filestem(), Some(b"def"));
/// assert_eq!(p.filestem(), Some(&b"def"[..]));
/// # }
/// ```
fn filestem<'a>(&'a self) -> Option<&'a [u8]> {
......@@ -392,7 +392,7 @@ fn filestem_str<'a>(&'a self) -> Option<&'a str> {
/// # #[cfg(windows)] fn foo() {}
/// # #[cfg(unix)] fn foo() {
/// let p = Path::new("abc/def.txt");
/// assert_eq!(p.extension(), Some(b"txt"));
/// assert_eq!(p.extension(), Some(&b"txt"[..]));
/// # }
/// ```
fn extension<'a>(&'a self) -> Option<&'a [u8]> {
......
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
const X1: &'static [u8] = &[b'1'];
const X2: &'static [u8] = b"1";
const X3: &'static [u8; 1] = &[b'1'];
const X4: &'static [u8; 1] = b"1";
static Y1: u8 = X1[0];
static Y2: u8 = X2[0];
static Y3: u8 = X3[0];
static Y4: u8 = X4[0];
fn main() {
assert_eq!(Y1, Y2);
assert_eq!(Y1, Y3);
assert_eq!(Y1, Y4);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册