Skip to content

Commit

Permalink
Add some runtime sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed May 21, 2018
1 parent d6fc3e1 commit 2788f66
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/test/ui/const-eval/strlen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-pass
// run-pass

#![feature(const_str_len, const_str_as_bytes)]

#![crate_type = "lib"]

const S: &str = "foo";
pub const B: &[u8] = S.as_bytes();

Expand All @@ -24,3 +22,12 @@ pub fn foo() -> [u8; S.len()] {
}
buf
}

fn main() {
assert_eq!(&foo()[..], b"foo");
assert_eq!(foo().len(), S.len());
const LEN: usize = S.len();
assert_eq!(LEN, S.len());
assert_eq!(B, foo());
assert_eq!(B, b"foo");
}

0 comments on commit 2788f66

Please sign in to comment.