crosvm/bit_field/tests/test_tuple_struct.rs
Daniel Verkamp 10990c89af Rust 1.65: Fix clippy derive_partial_eq_without_eq lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: Ib2b595385ed04b9480b22549334ce798d980d347
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064717
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-12-01 01:32:30 +00:00

27 lines
588 B
Rust

// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use bit_field::*;
#[bitfield]
#[bits = 5]
#[derive(Debug, PartialEq, Eq)]
pub struct FiveBits(u8);
#[bitfield]
struct Struct {
prefix: BitField1,
five_bits: FiveBits,
suffix: BitField2,
}
#[test]
fn test_enum() {
let mut s = Struct::new();
assert_eq!(s.get(0, 8), 0b_0000_0000);
s.set_five_bits(FiveBits(0b10101));
assert_eq!(s.get(0, 8), 0b_0010_1010);
assert_eq!(s.get_five_bits(), FiveBits(0b10101));
}