mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
66 lines
2.7 KiB
Zig
66 lines
2.7 KiB
Zig
const std = @import("../../std.zig");
|
|
const builtin = @import("builtin");
|
|
const windows = std.os.windows;
|
|
const mem = std.mem;
|
|
const testing = std.testing;
|
|
const expect = testing.expect;
|
|
|
|
fn testRemoveDotDirs(str: []const u8, expected: []const u8) !void {
|
|
const mutable = try testing.allocator.dupe(u8, str);
|
|
defer testing.allocator.free(mutable);
|
|
const actual = mutable[0..try windows.removeDotDirsSanitized(u8, mutable)];
|
|
try testing.expect(mem.eql(u8, actual, expected));
|
|
}
|
|
fn testRemoveDotDirsError(err: anyerror, str: []const u8) !void {
|
|
const mutable = try testing.allocator.dupe(u8, str);
|
|
defer testing.allocator.free(mutable);
|
|
try testing.expectError(err, windows.removeDotDirsSanitized(u8, mutable));
|
|
}
|
|
test "removeDotDirs" {
|
|
try testRemoveDotDirs("", "");
|
|
try testRemoveDotDirs(".", "");
|
|
try testRemoveDotDirs(".\\", "");
|
|
try testRemoveDotDirs(".\\.", "");
|
|
try testRemoveDotDirs(".\\.\\", "");
|
|
try testRemoveDotDirs(".\\.\\.", "");
|
|
|
|
try testRemoveDotDirs("a", "a");
|
|
try testRemoveDotDirs("a\\", "a\\");
|
|
try testRemoveDotDirs("a\\b", "a\\b");
|
|
try testRemoveDotDirs("a\\.", "a\\");
|
|
try testRemoveDotDirs("a\\b\\.", "a\\b\\");
|
|
try testRemoveDotDirs("a\\.\\b", "a\\b");
|
|
|
|
try testRemoveDotDirs(".a", ".a");
|
|
try testRemoveDotDirs(".a\\", ".a\\");
|
|
try testRemoveDotDirs(".a\\.b", ".a\\.b");
|
|
try testRemoveDotDirs(".a\\.", ".a\\");
|
|
try testRemoveDotDirs(".a\\.\\.", ".a\\");
|
|
try testRemoveDotDirs(".a\\.\\.\\.b", ".a\\.b");
|
|
try testRemoveDotDirs(".a\\.\\.\\.b\\", ".a\\.b\\");
|
|
|
|
try testRemoveDotDirsError(error.TooManyParentDirs, "..");
|
|
try testRemoveDotDirsError(error.TooManyParentDirs, "..\\");
|
|
try testRemoveDotDirsError(error.TooManyParentDirs, ".\\..\\");
|
|
try testRemoveDotDirsError(error.TooManyParentDirs, ".\\.\\..\\");
|
|
|
|
try testRemoveDotDirs("a\\..", "");
|
|
try testRemoveDotDirs("a\\..\\", "");
|
|
try testRemoveDotDirs("a\\..\\.", "");
|
|
try testRemoveDotDirs("a\\..\\.\\", "");
|
|
try testRemoveDotDirs("a\\..\\.\\.", "");
|
|
try testRemoveDotDirsError(error.TooManyParentDirs, "a\\..\\.\\.\\..");
|
|
|
|
try testRemoveDotDirs("a\\..\\.\\.\\b", "b");
|
|
try testRemoveDotDirs("a\\..\\.\\.\\b\\", "b\\");
|
|
try testRemoveDotDirs("a\\..\\.\\.\\b\\.", "b\\");
|
|
try testRemoveDotDirs("a\\..\\.\\.\\b\\.\\", "b\\");
|
|
try testRemoveDotDirs("a\\..\\.\\.\\b\\.\\..", "");
|
|
try testRemoveDotDirs("a\\..\\.\\.\\b\\.\\..\\", "");
|
|
try testRemoveDotDirs("a\\..\\.\\.\\b\\.\\..\\.", "");
|
|
try testRemoveDotDirsError(error.TooManyParentDirs, "a\\..\\.\\.\\b\\.\\..\\.\\..");
|
|
|
|
try testRemoveDotDirs("a\\b\\..\\", "a\\");
|
|
try testRemoveDotDirs("a\\b\\..\\c", "a\\c");
|
|
}
|