use rit; #[test] fn rit_eq1() { assert_eq!(rit::eq1!(0b0000_1111, 0), true); assert_eq!(rit::eq1!(0b0000_1111, 1), true); assert_eq!(rit::eq1!(0b0000_1111, 2), true); assert_eq!(rit::eq1!(0b0000_1111, 3), true); assert_eq!(rit::eq1!(0b0000_1111, 4), false); assert_eq!(rit::eq1!(0b0000_1111, 5), false); assert_eq!(rit::eq1!(0b0000_1111, 6), false); assert_eq!(rit::eq1!(0b0000_1111, 7), false); let a: u32 = 0x00000000f0; assert_eq!(rit::eq1!(a, 0), false); assert_eq!(rit::eq1!(a, 1), false); assert_eq!(rit::eq1!(a, 2), false); assert_eq!(rit::eq1!(a, 3), false); assert_eq!(rit::eq1!(a, 4), true); assert_eq!(rit::eq1!(a, 5), true); assert_eq!(rit::eq1!(a, 6), true); assert_eq!(rit::eq1!(a, 7), true); } #[test] fn rit_set() { assert_eq!(rit::set!(0b0000_1111, 0), 0x0f); assert_eq!(rit::set!(0b0000_1111, 1), 0x0f); assert_eq!(rit::set!(0b0000_1111, 2), 0x0f); assert_eq!(rit::set!(0b0000_1111, 3), 0x0f); assert_eq!(rit::set!(0b0000_1111, 4), 0x1f); assert_eq!(rit::set!(0b0000_1111, 5), 0x2f); assert_eq!(rit::set!(0b0000_1111, 6), 0x4f); assert_eq!(rit::set!(0b0000_1111, 7), 0x8f); let a: u32 = 0x00000000f0; assert_eq!(rit::set!(a, 0), 0x00000000f1); assert_eq!(rit::set!(a, 1), 0x00000000f2); assert_eq!(rit::set!(a, 2), 0x00000000f4); assert_eq!(rit::set!(a, 3), 0x00000000f8); assert_eq!(rit::set!(a, 4), 0x00000000f0); assert_eq!(rit::set!(a, 5), 0x00000000f0); assert_eq!(rit::set!(a, 6), 0x00000000f0); assert_eq!(rit::set!(a, 7), 0x00000000f0); } #[test] fn rit_clr() { assert_eq!(rit::clr!(0b0000_1111, 0), 0x0e); assert_eq!(rit::clr!(0b0000_1111, 1), 0x0d); assert_eq!(rit::clr!(0b0000_1111, 2), 0x0b); assert_eq!(rit::clr!(0b0000_1111, 3), 0x07); assert_eq!(rit::clr!(0b0000_1111, 4), 0x0f); assert_eq!(rit::clr!(0b0000_1111, 5), 0x0f); assert_eq!(rit::clr!(0b0000_1111, 6), 0x0f); assert_eq!(rit::clr!(0b0000_1111, 7), 0x0f); let a: u32 = 0x00000000f0; assert_eq!(rit::clr!(a, 0), 0x00000000f0); assert_eq!(rit::clr!(a, 1), 0x00000000f0); assert_eq!(rit::clr!(a, 2), 0x00000000f0); assert_eq!(rit::clr!(a, 3), 0x00000000f0); assert_eq!(rit::clr!(a, 4), 0x00000000e0); assert_eq!(rit::clr!(a, 5), 0x00000000d0); assert_eq!(rit::clr!(a, 6), 0x00000000b0); assert_eq!(rit::clr!(a, 7), 0x0000000070); }