]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/integral-indexing.rs
cbbe101c58a34fc73a67c49be0156604bfa9b3d5
[rust.git] / src / test / run-pass / integral-indexing.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12
13
14 // This is a testcase for issue #94.
15 pub fn main() {
16     let v: Vec<int> = vec!(0, 1, 2, 3, 4, 5);
17     let s: ~str = ~"abcdef";
18     assert_eq!(v[3u], 3);
19     assert_eq!(v[3u8], 3);
20     assert_eq!(v[3i8], 3);
21     assert_eq!(v[3u32], 3);
22     assert_eq!(v[3i32], 3);
23     println!("{}", v[3u8]);
24     assert_eq!(s[3u], 'd' as u8);
25     assert_eq!(s[3u8], 'd' as u8);
26     assert_eq!(s[3i8], 'd' as u8);
27     assert_eq!(s[3u32], 'd' as u8);
28     assert_eq!(s[3i32], 'd' as u8);
29     println!("{}", s[3u8]);
30 }