mirror of
https://github.com/awfixers-stuff/src.git
synced 2026-03-27 21:06:00 +00:00
create src
This commit is contained in:
42
src-discover/tests/discover/parse.rs
Normal file
42
src-discover/tests/discover/parse.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
use std::path::Path;
|
||||
|
||||
use gix_discover::parse;
|
||||
|
||||
#[test]
|
||||
fn valid() -> crate::Result {
|
||||
assert_eq!(parse::gitdir(b"gitdir: a")?, Path::new("a"));
|
||||
assert_eq!(parse::gitdir(b"gitdir: relative/path")?, Path::new("relative/path"));
|
||||
assert_eq!(parse::gitdir(b"gitdir: ./relative/path")?, Path::new("./relative/path"));
|
||||
assert_eq!(parse::gitdir(b"gitdir: /absolute/path\n")?, Path::new("/absolute/path"));
|
||||
assert_eq!(
|
||||
parse::gitdir(b"gitdir: C:/hello/there\r\n")?,
|
||||
Path::new("C:/hello/there")
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid() {
|
||||
assert!(
|
||||
matches!(
|
||||
parse::gitdir(b"gitdir:"),
|
||||
Err(parse::gitdir::Error::InvalidFormat { .. })
|
||||
),
|
||||
"missing prefix"
|
||||
);
|
||||
assert!(
|
||||
matches!(
|
||||
parse::gitdir(b"bogus: foo"),
|
||||
Err(parse::gitdir::Error::InvalidFormat { .. })
|
||||
),
|
||||
"invalid prefix"
|
||||
);
|
||||
assert!(
|
||||
matches!(
|
||||
parse::gitdir(b"gitdir: "),
|
||||
Err(parse::gitdir::Error::InvalidFormat { .. })
|
||||
),
|
||||
"empty path"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user