fix: normalize away './' path prefixes

This commit is contained in:
CJ van den Berg 2025-10-23 23:24:58 +02:00
parent 5b23998376
commit e053a0dcf4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
5 changed files with 53 additions and 10 deletions

View file

@ -2,6 +2,7 @@ const std = @import("std");
pub const buffer = @import("tests_buffer.zig");
pub const color = @import("tests_color.zig");
pub const helix = @import("tests_helix.zig");
pub const project_manager = @import("tests_project_manager.zig");
test {
std.testing.refAllDecls(@This());

View file

@ -0,0 +1,19 @@
const std = @import("std");
const pm = @import("project_manager");
test "normalize_file_path_dot_prefix" {
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix("example.txt"));
try std.testing.expectEqualStrings("/example.txt", pm.normalize_file_path_dot_prefix("/example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix("./example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix("././example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix(".//example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix(".//./example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix(".//.//example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix("./../example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix(".//../example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix("././../example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix("././/../example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix(".//.//../example.txt"));
try std.testing.expectEqualStrings("./", pm.normalize_file_path_dot_prefix("./"));
try std.testing.expectEqualStrings(".", pm.normalize_file_path_dot_prefix("."));
}