|
92 | 92 |
|
93 | 93 | #-------------------------------------------------------------------------------
|
94 | 94 | @testset "Data set name parsing" begin
|
95 |
| - # Valid names |
96 |
| - @test DataSets.check_dataset_name("a_b") === nothing |
97 |
| - @test DataSets.check_dataset_name("a1") === nothing |
98 |
| - @test DataSets.check_dataset_name("δεδομένα") === nothing |
99 |
| - @test DataSets.check_dataset_name("a/b") === nothing |
100 |
| - @test DataSets.check_dataset_name("a/b/c") === nothing |
101 |
| - @test DataSets.check_dataset_name("a-b-c-") === nothing |
102 |
| - # Invalid names |
103 |
| - @test_throws ErrorException("DataSet name \"a?b\" is invalid. DataSet names must start with a letter and can contain only letters, numbers, `-`, `_` or `/`.") DataSets.check_dataset_name("a?b") |
104 |
| - @test_throws ErrorException DataSets.check_dataset_name("1") |
105 |
| - @test_throws ErrorException DataSets.check_dataset_name("a b") |
106 |
| - @test_throws ErrorException DataSets.check_dataset_name("a.b") |
107 |
| - @test_throws ErrorException DataSets.check_dataset_name("a/b/") |
108 |
| - @test_throws ErrorException DataSets.check_dataset_name("/a/b") |
| 95 | + @testset "Valid name: $name" for name in ( |
| 96 | + "a_b", "a-b", "a1", "δεδομένα", "a/b", "a/b/c", "a-", "b_", |
| 97 | + ) |
| 98 | + @test DataSets.check_dataset_name(name) === nothing |
| 99 | + @test DataSets._split_dataspec(name) == (name, nothing, nothing) |
| 100 | + end |
| 101 | + |
| 102 | + @testset "Invalid name: $name" for name in ( |
| 103 | + "1", "a b", "a.b", "a/b/", "a//b", "/a/b", "a/-", "a/1", "a/ _/b" |
| 104 | + ) |
| 105 | + @test_throws ErrorException DataSets.check_dataset_name(name) |
| 106 | + @test DataSets._split_dataspec(name) == (nothing, nothing, nothing) |
| 107 | + end |
109 | 108 | end
|
110 | 109 |
|
111 | 110 | @testset "URL-like dataspec parsing" begin
|
| 111 | + # Valid dataspecs |
| 112 | + DataSets._split_dataspec("foo?x=1#f") == ("foo", ["x" => "1"], "f") |
| 113 | + DataSets._split_dataspec("foo#f") == ("foo", nothing, "f") |
| 114 | + DataSets._split_dataspec("foo?x=1") == ("foo", ["x" => "1"], nothing) |
| 115 | + DataSets._split_dataspec("foo?x=1") == ("foo", ["x" => "1"], nothing) |
| 116 | + # Invalid dataspecs |
| 117 | + DataSets._split_dataspec("foo ?x=1") == (nothing, nothing, nothing) |
| 118 | + DataSets._split_dataspec("foo\n?x=1") == (nothing, nothing, nothing) |
| 119 | + DataSets._split_dataspec("foo\nbar?x=1") == (nothing, nothing, nothing) |
| 120 | + DataSets._split_dataspec(" foo?x=1") == (nothing, nothing, nothing) |
| 121 | + DataSets._split_dataspec("1?x=1") == (nothing, nothing, nothing) |
| 122 | + DataSets._split_dataspec("foo-?x=1") == (nothing, nothing, nothing) |
| 123 | + DataSets._split_dataspec("foo #f") == (nothing, nothing, nothing) |
| 124 | + DataSets._split_dataspec("@?x=1") == (nothing, nothing, nothing) |
| 125 | + |
112 | 126 | proj = DataSets.load_project("Data.toml")
|
113 | 127 |
|
114 | 128 | @test !haskey(dataset(proj, "a_text_file"), "dataspec")
|
|
0 commit comments