100-days-of-rust/Week-10/Day-65_ISBN-Validator/day65/tests/examples.rs

36 lines
670 B
Rust
Raw Normal View History

2024-09-28 07:38:00 +00:00
#[cfg(test)]
mod examples {
use day65::isbn_validator;
#[test]
fn example1() {
assert!(isbn_validator("0747532699").unwrap());
}
#[test]
fn example2() {
assert!(isbn_validator("123456789X").unwrap());
}
#[test]
fn example3() {
assert!(!isbn_validator("1234567890").unwrap());
}
#[test]
fn example4() {
assert_eq!(
isbn_validator("abcdefghil"),
Err("Only digits allowed".to_owned())
)
}
#[test]
fn example5() {
assert_eq!(
isbn_validator("123"),
Err("Invalid length for the ISBN".to_owned())
)
}
}