decon-spf 0.3.3

This is a simple tool that allows you to deconstruct an existing SPF record that might be retreived in a normal DNS TXT lookup. With version 0.2.0 you can now also construct a new Spf record.
Documentation
mod general {

    use crate::spf::mechanism::{Mechanism, MechanismError};

    #[test]
    fn unsupported_mechanism_str() {
        let input = "redirect:_spf.example.com";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
        assert_eq!(err.is_invalid_format(), true);
    }
    #[test]
    fn unsupported_mechanism_str_a() {
        let input = "abc.com";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(err.is_invalid_format(), true);
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
    }
    #[test]
    fn unsupported_mechanism_str_mx() {
        let input = "+mx.com";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(err.is_invalid_format(), true);
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
    }
    #[test]
    fn supported_mechanism_str_ends_with_colon() {
        let input = "+mx:";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(err.is_invalid_format(), true);
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
    }
    #[test]
    fn supported_mechanism_str_ends_with_slash() {
        let input = "+a/";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(err.is_invalid_format(), true);
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
    }
    #[test]
    fn blank_exists() {
        let input = "exists";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(err.is_invalid_format(), true);
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
    }
    #[test]
    fn blank_exists_colon() {
        let input = "exists:";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(err.is_invalid_format(), true);
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
    }
    #[test]
    fn exists_slash() {
        let input = "exists:test.com/";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(err.is_invalid_format(), true);
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
    }
    #[test]
    fn exists_slash_cidr() {
        let input = "exists:test.com/24";

        let m: Result<Mechanism<String>, MechanismError> = input.parse();
        assert_eq!(m.is_err(), true);
        let err = m.unwrap_err();
        assert_eq!(err.is_invalid_format(), true);
        assert_eq!(
            err,
            MechanismError::InvalidMechanismFormat(input.to_string())
        );
    }
}