|
| 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. |
| 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 | +pub fn main() |
| 12 | +{ |
| 13 | + let all_nuls1 = "\0\x00\u0000\U00000000"; |
| 14 | + let all_nuls2 = "\U00000000\u0000\x00\0"; |
| 15 | + let all_nuls3 = "\u0000\U00000000\x00\0"; |
| 16 | + let all_nuls4 = "\x00\u0000\0\U00000000"; |
| 17 | + |
| 18 | + // sizes for two should suffice |
| 19 | + assert_eq!(all_nuls1.len(), 4); |
| 20 | + assert_eq!(all_nuls2.len(), 4); |
| 21 | + |
| 22 | + // string equality should pass between the strings |
| 23 | + assert_eq!(all_nuls1, all_nuls2); |
| 24 | + assert_eq!(all_nuls2, all_nuls3); |
| 25 | + assert_eq!(all_nuls3, all_nuls4); |
| 26 | + |
| 27 | + // all extracted characters in all_nuls are equivalent to each other |
| 28 | + for c1 in all_nuls1.iter() |
| 29 | + { |
| 30 | + for c2 in all_nuls1.iter() |
| 31 | + { |
| 32 | + assert_eq!(c1,c2); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + // testing equality between explicit character literals |
| 37 | + assert_eq!('\0', '\x00'); |
| 38 | + assert_eq!('\u0000', '\x00'); |
| 39 | + assert_eq!('\u0000', '\U00000000'); |
| 40 | + |
| 41 | + // NUL characters should make a difference |
| 42 | + assert!("Hello World" != "Hello \0World"); |
| 43 | + assert!("Hello World" != "Hello World\0"); |
| 44 | +} |
0 commit comments