// SPDX-License-Identifier: MIT OR Apache-2.0
// Copyright (c) 2025 lacklustr@protonmail.com https://github.com/eadf
macro_rules! integrity_assert {
    ($cond:expr) => {
        #[cfg(any(feature = "integrity_check", debug_assertions))]
        assert!($cond);
    };
    ($cond:expr, $($arg:tt)*) => {
        #[cfg(any(feature = "integrity_check", debug_assertions))]
        assert!($cond, $($arg)*);
    };
}

macro_rules! integrity_assert_unique {
    ($($var:ident),+) => {
        #[cfg(any(feature = "integrity_check", debug_assertions))]
        {
            let vars = [$(&$var),+];
            for i in 0..vars.len() {
                for j in (i + 1)..vars.len() {
                    assert!(vars[i] != vars[j], "Duplicate values found: {:?} == {:?}", vars[i], vars[j]);
                }
            }
        }
    };
}

macro_rules! integrity_assert_eq {
    ($left:expr, $right:expr) => {
        #[cfg(any(feature = "integrity_check", debug_assertions))]
        assert_eq!($left, $right);
    };
    ($left:expr, $right:expr, $($arg:tt)*) => {
        #[cfg(any(feature = "integrity_check", debug_assertions))]
        assert_eq!($left, $right, $($arg)*);
    };
}

macro_rules! integrity_assert_ne {
    ($left:expr, $right:expr) => {
        #[cfg(any(feature = "integrity_check", debug_assertions))]
        assert_ne!($left, $right);
    };
    ($left:expr, $right:expr, $($arg:tt)*) => {
        #[cfg(any(feature = "integrity_check", debug_assertions))]
        assert_ne!($left, $right, $($arg)*);
    };
}

#[allow(unused_macros)]
macro_rules! integrity_print {
    ($($arg:tt)*) => {
        #[cfg(feature = "integrity_check")]
        print!($($arg)*);
    };
}

macro_rules! integrity_println {
    ($($arg:tt)*) => {
        #[cfg(feature = "integrity_check")]
        println!($($arg)*);
    };
}

pub(crate) use integrity_assert;
pub(crate) use integrity_assert_eq;
pub(crate) use integrity_assert_ne;
pub(crate) use integrity_assert_unique;
pub(crate) use integrity_print;
pub(crate) use integrity_println;
