2019-07-26 21:54:25 +00:00
|
|
|
// run-pass
|
|
|
|
|
2013-09-17 02:38:53 +00:00
|
|
|
pub fn main()
|
|
|
|
{
|
2015-03-06 21:57:44 +00:00
|
|
|
let all_nuls1 = "\0\x00\u{0}\u{0}";
|
|
|
|
let all_nuls2 = "\u{0}\u{0}\x00\0";
|
|
|
|
let all_nuls3 = "\u{0}\u{0}\x00\0";
|
|
|
|
let all_nuls4 = "\x00\u{0}\0\u{0}";
|
2013-09-17 02:38:53 +00:00
|
|
|
|
|
|
|
// sizes for two should suffice
|
2013-11-23 10:18:51 +00:00
|
|
|
assert_eq!(all_nuls1.len(), 4);
|
2013-09-17 02:38:53 +00:00
|
|
|
assert_eq!(all_nuls2.len(), 4);
|
|
|
|
|
|
|
|
// string equality should pass between the strings
|
|
|
|
assert_eq!(all_nuls1, all_nuls2);
|
|
|
|
assert_eq!(all_nuls2, all_nuls3);
|
|
|
|
assert_eq!(all_nuls3, all_nuls4);
|
2013-11-23 10:18:51 +00:00
|
|
|
|
2013-09-17 02:38:53 +00:00
|
|
|
// all extracted characters in all_nuls are equivalent to each other
|
2013-11-23 10:18:51 +00:00
|
|
|
for c1 in all_nuls1.chars()
|
2013-09-17 02:38:53 +00:00
|
|
|
{
|
2013-11-23 10:18:51 +00:00
|
|
|
for c2 in all_nuls1.chars()
|
2013-09-17 02:38:53 +00:00
|
|
|
{
|
|
|
|
assert_eq!(c1,c2);
|
|
|
|
}
|
|
|
|
}
|
2013-11-23 10:18:51 +00:00
|
|
|
|
2013-09-17 02:38:53 +00:00
|
|
|
// testing equality between explicit character literals
|
|
|
|
assert_eq!('\0', '\x00');
|
2015-03-06 21:57:44 +00:00
|
|
|
assert_eq!('\u{0}', '\x00');
|
|
|
|
assert_eq!('\u{0}', '\u{0}');
|
2013-09-17 02:38:53 +00:00
|
|
|
|
|
|
|
// NUL characters should make a difference
|
|
|
|
assert!("Hello World" != "Hello \0World");
|
|
|
|
assert!("Hello World" != "Hello World\0");
|
|
|
|
}
|