Function swift_check::eq

source ·
pub const fn eq(expected: u8) -> impl Fn(Vector) -> Vector
Expand description

Check if the bytes are equal to expected

§Arguments

  • expected - The value you expect

§Example

use swift_check::{ensure, any, eq, arch::load};

let input = b"1111111111111111";
let data = load(input);

let has_one = ensure!(data, eq(b'1'));
assert!(has_one);

let input = b"2112111211211211";
let data = load(input);

let has_one_or_two = ensure!(data, any!(eq(b'1'), eq(b'2')));
assert!(has_one_or_two);

let input = b"3452111211211211";
let data = load(input);

let should_fail = ensure!(data, any!(eq(b'1'), eq(b'2')));
assert!(!should_fail);