Skip to content

Commit

Permalink
Test both URIParser and URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkuhn committed Apr 23, 2021
1 parent 3809382 commit aa8e582
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ URIParser = "30578b45-9adc-5946-b283-645ec420af67"
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"

[targets]
test = ["Glob", "Test", "URIs"]
test = ["Glob", "Test", "URIParser", "URIs"]
3 changes: 1 addition & 2 deletions src/uriparser.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using .URIParser

Base.depwarn("`URIParser` is deprecated, use `URIs` instead.", :URIParser, force=true)

function URIParser.URI(p::AbstractPath; query="", fragment="")
Base.depwarn("`URIParser` is deprecated, use `URIs` instead.", :URIParser)
if isempty(p.root)
throw(ArgumentError("$p is not an absolute path"))
end
Expand Down
21 changes: 15 additions & 6 deletions test/test_uri.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
using URIParser
using URIs
using FilePaths

@testset "URI" begin
@test string(URI(p"/foo/bar")) == "file:///foo/bar"
@test string(URI(p"/foo foo/bar")) == "file:///foo%20foo/bar"
@test_throws ArgumentError URI(p"foo/bar")
@test string(URI(WindowsPath("C:\\foo\\bar"))) == "file:///C:/foo/bar"
@test string(URI(p"/foo/bar", query="querypart", fragment="fragmentpart")) == "file:///foo/bar?querypart#fragmentpart"
@testset "URIParser" begin
@test string(URIParser.URI(p"/foo/bar")) == "file:///foo/bar"
@test string(URIParser.URI(p"/foo foo/bar")) == "file:///foo%20foo/bar"
@test_throws ArgumentError URIParser.URI(p"foo/bar")
@test string(URIParser.URI(WindowsPath("C:\\foo\\bar"))) == "file:///C:/foo/bar"
@test string(URIParser.URI(p"/foo/bar", query="querypart", fragment="fragmentpart")) == "file:///foo/bar?querypart#fragmentpart"
end

@testset "URIs" begin
@test string(URIs.URI(p"/foo/bar")) == "file:///foo/bar"
@test string(URIs.URI(p"/foo foo/bar")) == "file:///foo%20foo/bar"
@test_throws ArgumentError URIs.URI(p"foo/bar")
@test string(URIs.URI(WindowsPath("C:\\foo\\bar"))) == "file:///C:/foo/bar"
@test string(URIs.URI(p"/foo/bar", query="querypart", fragment="fragmentpart")) == "file:///foo/bar?querypart#fragmentpart"
end

0 comments on commit aa8e582

Please sign in to comment.