test_with

Attribute Macro timezone

source
#[timezone]
Expand description

Run test case when the timezone is expected.

#[cfg(test)]
mod tests {

    // 0 means UTC
    #[test_with::timezone(0)]
    #[test]
    fn test_works() {
        assert!(true);
    }

    // UTC is GMT+0
    #[test_with::timezone(UTC)]
    #[test]
    fn test_works_too() {
        assert!(true);
    }

    // +8 means GMT+8
    #[test_with::timezone(+8)]
    #[test]
    fn test_ignored() {
        panic!("should be ignored")
    }

    // HKT GMT+8
    #[test_with::timezone(HKT)]
    #[test]
    fn test_ignored_too() {
        panic!("should be ignored")
    }
}