Debian Codegraph @

.cargo/vendor/zerocopy-derive/tests/eq.rs

raw
1 // Copyright 2024 The Fuchsia Authors
2 //
3 // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
4 // <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
5 // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
6 // This file may not be copied, modified, or distributed except according to
7 // those terms.
8
9 // See comment in `include.rs` for why we disable the prelude.
10 #![no_implicit_prelude]
11 #![allow(warnings)]
12
13 include!("include.rs");
14
15 #[derive(imp::Debug, imp::IntoBytes, imp::Immutable, imp::ByteEq)]
16 #[repr(C)]
17 struct Struct {
18 a: u64,
19 b: u32,
20 c: u32,
21 }
22
23 util_assert_impl_all!(Struct: imp::IntoBytes, imp::PartialEq, imp::Eq);
24
25 #[test]
26 fn test_eq() {
27 use imp::{assert_eq, assert_ne};
28 let a = Struct { a: 10, b: 15, c: 20 };
29 let b = Struct { a: 10, b: 15, c: 25 };
30 assert_eq!(a, a);
31 assert_ne!(a, b);
32 assert_ne!(b, a);
33 }