use pactum_annotations::{
check_hex, check_hostname, check_ip, check_ipv4, check_ipv6, check_semver,
};
use proptest::prelude::*;
proptest! {
#[test]
fn network_and_version_validators_never_panic(s in "\\PC*") {
let _ = check_ipv4("f", &s);
let _ = check_ipv6("f", &s);
let _ = check_ip("f", &s);
let _ = check_hostname("f", &s);
let _ = check_semver("f", &s);
let _ = check_hex("f", &s);
}
#[test]
fn ipv4_round_trips(a in any::<u8>(), b in any::<u8>(), c in any::<u8>(), d in any::<u8>()) {
let s = format!("{}.{}.{}.{}", a, b, c, d);
prop_assert!(check_ipv4("f", &s).is_ok());
prop_assert!(check_ip("f", &s).is_ok());
prop_assert!(check_ipv6("f", &s).is_err());
}
#[test]
fn semver_accepts_canonical_triples(a in 0u32..1000, b in 0u32..1000, c in 0u32..1000) {
let plain = format!("{}.{}.{}", a, b, c);
let full = format!("{}.{}.{}-rc.1+build.7", a, b, c);
prop_assert!(check_semver("f", &plain).is_ok());
prop_assert!(check_semver("f", &full).is_ok());
}
#[test]
fn hex_accepts_only_hex_digits(s in "[0-9a-fA-F]{1,64}") {
prop_assert!(check_hex("f", &s).is_ok());
let polluted = format!("{s}g");
prop_assert!(check_hex("f", &polluted).is_err());
}
#[test]
fn hostname_accepts_simple_labels(labels in proptest::collection::vec("[a-z][a-z0-9]{0,10}", 1..4)) {
let host = labels.join(".");
prop_assert!(check_hostname("f", &host).is_ok());
}
}