advent_of_code_2024/helpers/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#[cfg(test)]
pub(crate) mod test {
    use std::fmt::Debug;
    
    #[allow(dead_code)]
    pub(crate) fn assert_contains_in_any_order<T>(
        actual: impl IntoIterator<Item = T>,
        expected: impl IntoIterator<Item = T>,
    ) where
        T: Debug + Eq,
    {
        let actual_vec: Vec<T> = actual.into_iter().collect();
        let expected_vec: Vec<T> = expected.into_iter().collect();
        assert_eq!(
            actual_vec.len(),
            expected_vec.len(),
            "The actual length of the does not match the expected length"
        );

        for expected_value in expected_vec {
            assert!(
                actual_vec.contains(&expected_value),
                "{:?} was not found",
                expected_value,
            );
        }
    }
}