]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/nul-characters.rs
1 // Copyright 2013 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.
14 let all_nuls1
= "\0\x00\u{0}\u{0}";
15 let all_nuls2
= "\u{0}\u{0}\x00\0";
16 let all_nuls3
= "\u{0}\u{0}\x00\0";
17 let all_nuls4
= "\x00\u{0}\0\u{0}";
19 // sizes for two should suffice
20 assert_eq
!(all_nuls1
.len(), 4);
21 assert_eq
!(all_nuls2
.len(), 4);
23 // string equality should pass between the strings
24 assert_eq
!(all_nuls1
, all_nuls2
);
25 assert_eq
!(all_nuls2
, all_nuls3
);
26 assert_eq
!(all_nuls3
, all_nuls4
);
28 // all extracted characters in all_nuls are equivalent to each other
29 for c1
in all_nuls1
.chars()
31 for c2
in all_nuls1
.chars()
37 // testing equality between explicit character literals
38 assert_eq
!('
\0'
, '
\x00'
);
39 assert_eq
!('
\u{0}'
, '
\x00'
);
40 assert_eq
!('
\u{0}'
, '
\u{0}'
);
42 // NUL characters should make a difference
43 assert
!("Hello World" != "Hello \0World");
44 assert
!("Hello World" != "Hello World\0");