clankerdiff-core 0.1.1

Renderer-independent diff and code review domain model
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use clankerdiff_core::{RepoPath, RepoPathError};

#[test]
fn validates_relative_utf8_paths() -> Result<(), RepoPathError> {
    assert!(RepoPath::new("src/é file.rs").is_ok());
    assert_eq!(RepoPath::new("../secret"), Err(RepoPathError::Traversal));
    assert_eq!(RepoPath::new("/absolute"), Err(RepoPathError::Absolute));
    assert_eq!(RepoPath::new("a//b"), Err(RepoPathError::Empty));
    assert_eq!(RepoPath::new("a\0b"), Err(RepoPathError::Nul));
    assert_eq!(RepoPath::new("a\\\\b")?.as_str(), "a\\\\b");
    Ok(())
}