]>
git.proxmox.com Git - rustc.git/blob - vendor/pretty_assertions/tests/assert_ne.rs
1 #[allow(unused_imports)]
2 use pretty_assertions
::{assert_eq, assert_ne}
;
4 #[should_panic(expected = r#"assertion failed: `(left != right)`
19 #[derive(Debug, PartialEq)]
23 dolor
: Result
<String
, String
>,
27 lorem
: "Hello World!",
29 dolor
: Ok("hey".to_string()),
37 expected
= r
#"assertion failed: `(left != right)`: custom panic message
42 lorem: "Hello World!",
52 fn assert_ne_custom() {
53 #[derive(Debug, PartialEq)]
57 dolor
: Result
<String
, String
>,
61 lorem
: "Hello World!",
63 dolor
: Ok("hey".to_string()),
66 assert_ne
!(x
, x
, "custom panic message");
71 fn assert_ne_non_empty_return() {
72 fn not_zero(x
: u32) -> u32 {
80 #[should_panic(expected = r#"assertion failed: `(left != right)`
82 \e[1mDiff\e[0m \e[31m< left\e[0m / \e[32mright >\e[0m :
83 \e[31m<\e[0m\e[1;48;5;52;31m-\e[0m\e[31m0.0\e[0m
84 \e[32m>\e[0m\e[32m0.0\e[0m
86 \e[1;4mNote\e[0m: According to the `PartialEq` implementation, both of the values are partially equivalent, even if the `Debug` outputs differ.
89 fn assert_ne_partial() {
90 // Workaround for https://github.com/rust-lang/rust/issues/47619
91 // can be removed, when we require rust 1.25 or higher
95 impl fmt
::Debug
for Foo
{
96 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
97 write
!(f
, "{:.1?}", self.0)
101 impl PartialEq
for Foo
{
102 fn eq(&self, other
: &Self) -> bool
{
107 assert_ne
!(Foo(-0.0), Foo(0.0));
111 #[should_panic(expected = r#"assertion failed: `(left != right)`
113 \e[1mBoth sides\e[0m:
116 lorem: "Hello World!",
125 fn assert_ne_trailing_comma() {
126 #[derive(Debug, PartialEq)]
130 dolor
: Result
<String
, String
>,
134 lorem
: "Hello World!",
136 dolor
: Ok("hey".to_string()),
144 expected
= r
#"assertion failed: `(left != right)`: custom panic message
146 \e[1mBoth sides\e[0m:
149 lorem: "Hello World!",
159 fn assert_ne_custom_trailing_comma() {
160 #[derive(Debug, PartialEq)]
164 dolor
: Result
<String
, String
>,
168 lorem
: "Hello World!",
170 dolor
: Ok("hey".to_string()),
173 assert_ne
!(x
, x
, "custom panic message",);