diff options
| author | Brad Clawsie <brad@b7j0c.org> | 2026-11-23 14:21:49 -0600 |
|---|---|---|
| committer | Brad Clawsie <brad@b7j0c.org> | 2026-11-23 14:21:49 -0600 |
| commit | f091cb475a1e53f84b9876cd45e11b531f660237 (patch) | |
| tree | 8929ad05507bfb7a67a7651f00ed00bf07d7f49d /learn_20/src | |
| parent | 2c4083a8ce5e4968c7d2bb4293aa865012764e57 (diff) | |
fix: learn_20 corrections
Diffstat (limited to 'learn_20/src')
| -rw-r--r-- | learn_20/src/main.rs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/learn_20/src/main.rs b/learn_20/src/main.rs index e2c3ce9..1975d70 100644 --- a/learn_20/src/main.rs +++ b/learn_20/src/main.rs @@ -130,12 +130,15 @@ mod tests { let version1 = Version::from_str("2.5.10").unwrap(); assert_eq!(version1, Version::new(2, 5, 10)); - let original = Version::new(10, 20, 30); - - let text = original.to_string(); - let parsed: Version = text.parse().unwrap(); - - assert_eq!(parsed, original); + for original in [ + Version::new(10,20,30), + Version::new(0,u32::MAX,0), + Version::new(99,99,99), + ] { + let text = original.to_string(); + let parsed: Version = text.parse().unwrap(); + assert_eq!(parsed, original); + } } #[test] @@ -150,4 +153,16 @@ mod tests { Err(ParseVersionError::InvalidComponent) ); } + + #[test] + fn test_error_display() { + for error in [ + ParseVersionError::WrongCount, + ParseVersionError::EmptyComponent, + ParseVersionError::InvalidComponent, + ParseVersionError::OutOfRange, + ] { + assert!(!error.to_string().is_empty()); + } + } } |
