Backlog/lib/zargs/tests/test_utils.zig

49 lines
1.5 KiB
Zig

const std = @import("std");
const utils = @import("utils");
test "toKebabCase: basic camelCase" {
const result = comptime utils.toKebabCase("verboseMode");
try std.testing.expectEqualStrings("verbose-mode", result);
}
test "toKebabCase: snake_case" {
const result = comptime utils.toKebabCase("output_file");
try std.testing.expectEqualStrings("output-file", result);
}
test "toKebabCase: uppercase acronym" {
const result = comptime utils.toKebabCase("HTTPServer");
try std.testing.expectEqualStrings("http-server", result);
}
test "toKebabCase: mixed formats" {
const result = comptime utils.toKebabCase("parse_XMLFile");
try std.testing.expectEqualStrings("parse-xml-file", result);
}
test "toKebabCase: single word" {
const result = comptime utils.toKebabCase("verbose");
try std.testing.expectEqualStrings("verbose", result);
}
test "toKebabCase: already kebab-case" {
const result = comptime utils.toKebabCase("log-level");
try std.testing.expectEqualStrings("log-level", result);
}
test "toKebabCase: empty string" {
const result = comptime utils.toKebabCase("");
try std.testing.expectEqualStrings("", result);
}
test "toKebabCase: complex examples" {
{
const result = comptime utils.toKebabCase("maxConnectionsPerHost");
try std.testing.expectEqualStrings("max-connections-per-host", result);
}
{
const result = comptime utils.toKebabCase("enableHTTPSRedirect");
try std.testing.expectEqualStrings("enable-https-redirect", result);
}
}