Sebastian Thielmake fmte0438074 years agoHistory
42 lines · 1.1 KB · Rust
RawDownload
use std::path::Path; use git_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"    );}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t