Skip to content

Commit

Permalink
Merge branch 'main' of github.com:kmgill/sciimg
Browse files Browse the repository at this point in the history
  • Loading branch information
kmgill committed Apr 3, 2023
2 parents 61e6652 + 2895961 commit a66b3b7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/path.rs
@@ -1,3 +1,4 @@
use std::env;
use std::ffi::OsStr;
use std::path::Path;

Expand Down Expand Up @@ -46,3 +47,10 @@ pub fn parent_writable(chk_path: &str) -> bool {
pub fn parent_exists_and_writable(chk_path: &str) -> bool {
parent_exists(chk_path) && parent_writable(chk_path)
}

pub fn cwd() -> String {
match env::current_dir().unwrap().as_os_str().to_str() {
Some(d) => String::from(d),
None => String::from("./"),
}
}
26 changes: 26 additions & 0 deletions tests/path.rs
@@ -0,0 +1,26 @@
use sciimg::path;

#[test]
fn test_file_exists() {
assert!(path::file_exists("Cargo.toml"));
}

#[test]
fn test_file_writable() {
assert!(path::file_writable("Cargo.toml"));
}

#[test]
fn test_parent_exists() {
assert!(path::parent_exists("Cargo.toml"));
}

#[test]
fn test_parent_writable() {
assert!(path::parent_writable("Cargo.toml"));
}

#[test]
fn test_parent_exists_and_writable() {
assert!(path::parent_exists_and_writable("Cargo.toml"));
}

0 comments on commit a66b3b7

Please sign in to comment.