File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ dir: std.fs.Dir,
18
18
indexes : std .StringHashMap (IndexRef ),
19
19
20
20
fn isValidName (name : []const u8 ) bool {
21
- for (name , 0 ) | c , i | {
21
+ for (name , 0.. ) | c , i | {
22
22
if (i == 0 ) {
23
23
switch (c ) {
24
24
'0' ... '9' , 'A' ... 'Z' , 'a' ... 'z' = > {},
@@ -34,8 +34,16 @@ fn isValidName(name: []const u8) bool {
34
34
return true ;
35
35
}
36
36
37
- const max_sub_dir_name_size = 10 ;
38
- const sub_dir_name_fmt = "{x:0>2}" ;
37
+ test "isValidName" {
38
+ try std .testing .expect (isValidName ("a" ));
39
+ try std .testing .expect (isValidName ("a1" ));
40
+ try std .testing .expect (isValidName ("a1-b" ));
41
+ try std .testing .expect (isValidName ("a1_b" ));
42
+ try std .testing .expect (! isValidName ("_1b2" ));
43
+ try std .testing .expect (! isValidName ("-1b2" ));
44
+ try std .testing .expect (! isValidName ("a/a" ));
45
+ try std .testing .expect (! isValidName (".foo" ));
46
+ }
39
47
40
48
pub fn init (allocator : std.mem.Allocator , dir : std.fs.Dir ) Self {
41
49
return .{
You can’t perform that action at this time.
0 commit comments