use nutype::nutype;
use crate::name::validation::{NameError, validate};
#[nutype(
validate(with = validate, error = NameError),
derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Display,
FromStr,
AsRef,
),
)]
pub struct ProjectName(String);
#[cfg(test)]
mod tests {
use crate::name::ProjectName;
#[test]
fn id_004_case_sensitive_equality() {
let upper = ProjectName::try_new("MyProj").unwrap();
let lower = ProjectName::try_new("myproj").unwrap();
assert_ne!(upper, lower);
}
#[test]
fn round_trip_via_try_new_and_display() {
let n = ProjectName::try_new("lib_core").unwrap();
assert_eq!(n.to_string(), "lib_core");
}
#[test]
fn round_trip_via_fromstr() {
let parsed: ProjectName = "lib_core".parse().unwrap();
assert_eq!(parsed.to_string(), "lib_core");
}
}