module Tests.Path open NUnit.Framework open Pentole open Pentole.TestsExtensions open Pentole.Path [] let constructor_test () = "/" |> Path.of_string |> Result.isOk |> Assert.is_true '\000' |> string |> Path.of_string |> Result.isOk |> Assert.is_false [] let absolute_test () = let is_absolute = function | (Absolute path | Relative path) -> System.IO.Path.IsPathFullyQualified path let test (s:string) = s |> Path.of_string |> Result.map is_absolute "/" |> test |> Assert.ok_is_true "//" |> test |> Assert.ok_is_true "tmp/" |> test |> Assert.ok_is_false "tmp" |> test |> Assert.ok_is_false "~" |> test |> Assert.ok_is_false "." |> test |> Assert.ok_is_false ".." |> test |> Assert.ok_is_false "../" |> test |> Assert.ok_is_false "../../" |> test |> Assert.ok_is_false "..a" |> test |> Assert.ok_is_false ":a" |> test |> Assert.ok_is_false "\\a" |> test |> Assert.ok_is_false "/etc/../" |> test |> Assert.ok_is_true "/tmp/Char:é" |> test |> Assert.ok_is_true [] let resolve_test () = let test (s:string) = s |> Path.of_string |> Result.map FileSystem.resolve |> Result.Unsafe.get let p (n: string ) = Path.of_string n |> Result.Unsafe.get "/" |> test |> Assert.ok_is_equal (p "/") "/etc/../" |> test |> Assert.ok_is_equal (p "/") "/etc/../etc" |> test |> Assert.ok_is_equal (p "/etc") [] let equality_test () = let p (n: string ) = Path.of_string n |> Result.Unsafe.get Assert.are_equal (p "/etc") (p "/etc/") (* [] let parent_test () = let p (n: string ) = Path.of_string n |> Result.get let test (s:string) = s |> Path.of_string |> Result.get |> parent "/" |> test |> Assert.are_equal [p "/"] "/etc/" |> test |> Assert.are_seq_equal ["/"] "/etc/conf" |> test |> Assert.are_seq_equal [p "/etc"] "/etc/../etc" |> test |> Assert.ok_is_equal (p "/etc") *)