]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/byte-literals.rs
1 // Copyright 2014 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.
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.
13 static FOO
: u8 = b'
\xF0'
;
14 static BAR
: &'
static [u8] = b
"a\xF0\t";
15 static BAR_FIXED
: &'
static [u8; 3] = b
"a\xF0\t";
16 static BAZ
: &'
static [u8] = br
"a\n";
19 let bar
: &'
static [u8] = b
"a\xF0\t";
20 let bar_fixed
: &'
static [u8; 3] = b
"a\xF0\t";
22 assert_eq
!(b'a'
, 97u8);
23 assert_eq
!(b'
\n'
, 10u8);
24 assert_eq
!(b'
\r'
, 13u8);
25 assert_eq
!(b'
\t'
, 9u8);
26 assert_eq
!(b'
\\'
, 92u8);
27 assert_eq
!(b'
\''
, 39u8);
28 assert_eq
!(b'
\"'
, 34u8);
29 assert_eq
!(b'
\0'
, 0u8);
30 assert_eq
!(b'
\xF0'
, 240u8);
31 assert_eq
!(FOO
, 240u8);
43 let expected
: &[_
] = &[97u8, 10u8, 13u8, 9u8, 92u8, 39u8, 34u8, 0u8, 240u8];
44 assert_eq
!(b
"a\n\r\t\\\'\"\0\xF0", expected
);
45 let expected
: &[_
] = &[97u8, 98u8];
48 let expected
: &[_
] = &[97u8, 240u8, 9u8];
49 assert_eq
!(BAR
, expected
);
50 assert_eq
!(BAR_FIXED
, expected
);
51 assert_eq
!(bar
, expected
);
52 assert_eq
!(bar_fixed
, expected
);
54 let val
= &[97u8, 10u8];
60 let buf
= vec
![97u8, 98, 99, 100];
61 assert_eq
!(match &buf
[0..3] {
67 let expected
: &[_
] = &[97u8, 92u8, 110u8];
68 assert_eq
!(BAZ
, expected
);
69 let expected
: &[_
] = &[97u8, 92u8, 110u8];
70 assert_eq
!(br
"a\n", expected
);
71 assert_eq
!(br
"a\n", b
"a\\n");
72 let expected
: &[_
] = &[97u8, 34u8, 35u8, 35u8, 98u8];
73 assert_eq
!(br
###"a"##b"###, expected);
74 assert_eq!(br###"a"##b"###, b"a\"##b");