Skip to content

Commit 2d07c49

Browse files
committed
Adds test for new lossy
Signed-off-by: David Gilligan-Cook <[email protected]>
1 parent fcd2c25 commit 2d07c49

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

crates/spk-schema/crates/foundation/src/name/name_test.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ fn test_opt_name_validation(#[case] input: &str) {
3535
super::validate_opt_name(input).unwrap();
3636
}
3737

38+
#[rstest]
39+
#[case("lowercase", "lowercase")]
40+
#[case("with-dashes", "with-dashes")]
41+
#[case("with_underscores", "with_underscores")]
42+
#[case("num000", "num000")]
43+
#[case("000-000", "000-000")]
44+
#[case("000_000", "000_000")]
45+
#[case("-----", "-----")]
46+
#[case("_____", "_____")]
47+
#[case("upperCase", "uppercase")]
48+
#[case("name!!", "name")]
49+
#[case("a", "a_")]
50+
fn test_opt_name_buf_new_lossy(#[case] input: &str, #[case] result: &str) {
51+
let opt_name = super::OptNameBuf::new_lossy(&String::from(input));
52+
assert_eq!(opt_name.base_name(), result);
53+
}
54+
3855
#[rstest]
3956
#[case("my_opt", None, "my_opt")]
4057
#[case("my-pkg.my_opt", Some("my-pkg"), "my_opt")]

0 commit comments

Comments
 (0)