Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
--global authored and NicholasLYang committed Jun 22, 2023
1 parent 288900b commit dd058ea
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions crates/turborepo-paths/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,42 @@ impl<T: AsRef<str>> IntoUnix for T {
output
}
}

#[cfg(test)]
mod tests {
use crate::{IntoSystem, IntoUnix};

#[test]
fn test_into_system() {
#[cfg(unix)]
{
assert_eq!("foo/bar".into_system(), "foo/bar");
assert_eq!("/foo/bar".into_system(), "/foo/bar");
assert_eq!("foo\\bar".into_system(), "foo\\bar");
}

#[cfg(windows)]
{
assert_eq!("foo/bar".into_system(), "foo\\bar");
assert_eq!("/foo/bar".into_system(), "\\foo\\bar");
assert_eq!("foo\\bar".into_system(), "foo\\bar");
}
}

#[test]
fn test_into_unix() {
#[cfg(unix)]
{
assert_eq!("foo/bar".into_unix(), "foo/bar");
assert_eq!("/foo/bar".into_unix(), "/foo/bar");
assert_eq!("foo\\bar".into_unix(), "foo\\bar");
}

#[cfg(windows)]
{
assert_eq!("foo/bar".into_unix(), "foo/bar");
assert_eq!("\\foo\\bar".into_unix(), "/foo/bar");
assert_eq!("foo\\bar".into_unix(), "foo/bar");
}
}
}

0 comments on commit dd058ea

Please sign in to comment.