use super::*;

#[test]
fn default_nanoid_uses_safe_alphabet_order() {
    let mut random = |size| Ok((0..size).map(|value| value as u8).collect());
    let id = nano_id_format(NANO_ALPHABET, 12, &mut random).expect("id formats");
    assert_eq!(id, "_-0123456789");
}

#[test]
fn nanoid_uses_canonical_rejection_loop() {
    let alphabet = b"abc";
    let mut sizes = Vec::new();
    let mut random = |size| {
        sizes.push(size);
        Ok([2, 255, 0, 1].into_iter().cycle().take(size).collect())
    };
    let id = nano_id_format(alphabet, 4, &mut random).expect("id formats");
    assert_eq!(id, "cabc");
    assert_eq!(sizes, vec![7]);
}

#[test]
fn nanoid_rejects_invalid_symbols() {
    let error = NanoId::new("not valid").expect_err("space is rejected");
    assert_eq!(error.type_name(), "NanoId");
}

#[test]
fn uuid_versions_are_checked() {
    let v4 = UuidV4::generate();
    assert!(UuidV7::new(v4.into_uuid()).is_err());
}
