|
78 | 78 |
|
79 | 79 | #------------------------------------------------------------------------------- |
80 | 80 | @testset "Data set names" begin |
81 | | - # Valid names |
82 | | - @test DataSets.is_valid_dataset_name("a_b") |
83 | | - @test DataSets.is_valid_dataset_name("a-b") |
84 | | - @test DataSets.is_valid_dataset_name("a1") |
85 | | - @test DataSets.is_valid_dataset_name("δεδομένα") |
86 | | - @test DataSets.is_valid_dataset_name("a/b") |
87 | | - @test DataSets.is_valid_dataset_name("a/b/c") |
88 | | - # Invalid names |
89 | | - @test !DataSets.is_valid_dataset_name("1") |
90 | | - @test !DataSets.is_valid_dataset_name("a b") |
91 | | - @test !DataSets.is_valid_dataset_name("a.b") |
92 | | - @test !DataSets.is_valid_dataset_name("a/b/") |
93 | | - @test !DataSets.is_valid_dataset_name("a//b") |
94 | | - @test !DataSets.is_valid_dataset_name("/a/b") |
| 81 | + @testset "Valid name: $name" for name in ( |
| 82 | + "a_b", "a-b", "a1", "δεδομένα", "a/b", "a/b/c", "a-", "b_", |
| 83 | + ) |
| 84 | + @test DataSets.is_valid_dataset_name(name) |
| 85 | + @test DataSets._split_dataspec(name) == (name, nothing, nothing) |
| 86 | + end |
| 87 | + |
| 88 | + @testset "Invalid name: $name" for name in ( |
| 89 | + "1", "a b", "a.b", "a/b/", "a//b", "/a/b", "a/-", "a/1", "a/ _/b" |
| 90 | + ) |
| 91 | + @test !DataSets.is_valid_dataset_name(name) |
| 92 | + @test DataSets._split_dataspec(name) == (nothing, nothing, nothing) |
| 93 | + end |
| 94 | + |
95 | 95 | # Error message for invalid names |
96 | 96 | @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") |
97 | 97 |
|
|
107 | 107 | end |
108 | 108 |
|
109 | 109 | @testset "URL-like dataspec parsing" begin |
| 110 | + # Valid dataspecs |
| 111 | + DataSets._split_dataspec("foo?x=1#f") == ("foo", ["x" => "1"], "f") |
| 112 | + DataSets._split_dataspec("foo#f") == ("foo", nothing, "f") |
| 113 | + DataSets._split_dataspec("foo?x=1") == ("foo", ["x" => "1"], nothing) |
| 114 | + DataSets._split_dataspec("foo?x=1") == ("foo", ["x" => "1"], nothing) |
| 115 | + # Invalid dataspecs |
| 116 | + DataSets._split_dataspec("foo ?x=1") == (nothing, nothing, nothing) |
| 117 | + DataSets._split_dataspec("foo\n?x=1") == (nothing, nothing, nothing) |
| 118 | + DataSets._split_dataspec("foo\nbar?x=1") == (nothing, nothing, nothing) |
| 119 | + DataSets._split_dataspec(" foo?x=1") == (nothing, nothing, nothing) |
| 120 | + DataSets._split_dataspec("1?x=1") == (nothing, nothing, nothing) |
| 121 | + DataSets._split_dataspec("foo-?x=1") == (nothing, nothing, nothing) |
| 122 | + DataSets._split_dataspec("foo #f") == (nothing, nothing, nothing) |
| 123 | + DataSets._split_dataspec("@?x=1") == (nothing, nothing, nothing) |
| 124 | + |
110 | 125 | proj = DataSets.load_project("Data.toml") |
111 | 126 |
|
112 | 127 | @test !haskey(dataset(proj, "a_text_file"), "dataspec") |
|
0 commit comments