Nothing to see here, move along
at main 44 lines 942 B view raw
1use lancer_core::path::extract_filename; 2use proptest::prelude::*; 3 4#[test] 5fn empty_input() { 6 assert_eq!(extract_filename(b""), b""); 7} 8 9#[test] 10fn no_slash() { 11 assert_eq!(extract_filename(b"hello.txt"), b"hello.txt"); 12} 13 14#[test] 15fn trailing_slash() { 16 assert_eq!(extract_filename(b"/usr/bin/"), b""); 17} 18 19#[test] 20fn root_only() { 21 assert_eq!(extract_filename(b"/"), b""); 22} 23 24#[test] 25fn nested_path() { 26 assert_eq!(extract_filename(b"/usr/local/bin/app"), b"app"); 27} 28 29proptest! { 30 #[test] 31 fn no_slash_returns_full_input(s in "[^/]{0,64}") { 32 let bytes = s.as_bytes(); 33 prop_assert_eq!(extract_filename(bytes), bytes); 34 } 35 36 #[test] 37 fn suffix_after_last_slash( 38 prefix in "[a-z/]{1,32}", 39 filename in "[a-z0-9.]{1,16}" 40 ) { 41 let path = [prefix.as_bytes(), b"/", filename.as_bytes()].concat(); 42 prop_assert_eq!(extract_filename(&path), filename.as_bytes()); 43 } 44}