author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
Thu, 16 Feb 2023 14:54:34 +0000 | |
changeset 50095 | 362fe34702d5 |
parent 50094 | 1cffc156f7cd |
child 50096 | 06659dea51b0 |
--- a/rust/hg-core/src/revlog/path_encode.rs Thu Feb 16 14:43:46 2023 +0000 +++ b/rust/hg-core/src/revlog/path_encode.rs Thu Feb 16 14:54:34 2023 +0000 @@ -643,3 +643,22 @@ hash_encode(path) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::utils::hg_path::HgPathBuf; + + // expected failure + #[test] + #[should_panic] + fn test_long_filename_at_root() { + let input = b"data/ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ.i"; + let expected = b"dh/abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij.i708243a2237a7afae259ea3545a72a2ef11c247b.i"; + let res = path_encode(input); + assert_eq!( + HgPathBuf::from_bytes(&res), + HgPathBuf::from_bytes(expected) + ); + } +}