-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std: Introduce SemanticVersion data structure #6566
Conversation
SemanticVersion
data structure00d49da
to
3d74b6c
Compare
This will parse, format, and compare version strings following the SemVer 2 specification. See: https://semver.org Updates ziglang#6466
3d74b6c
to
ef0d2a7
Compare
Okay, I think this is in decent shape and ready for review. One question I have for reviewers is what to do about |
fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void { | ||
var buf: [100]u8 = undefined; | ||
const result = try std.fmt.bufPrint(buf[0..], template, args); | ||
if (std.mem.eql(u8, result, expected)) return; | ||
|
||
std.debug.warn("\n====== expected this output: =========\n", .{}); | ||
std.debug.warn("{}", .{expected}); | ||
std.debug.warn("\n======== instead found this: =========\n", .{}); | ||
std.debug.warn("{}", .{result}); | ||
std.debug.warn("\n======================================\n", .{}); | ||
return error.TestFailed; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we move it into std.testing
and make it public? Would that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense to me. I suppose I should do that in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR created: #6831
This will enable easier testing for custom formatting implementations. Motivated by copy-pasted code in PR ziglang#6566.
This will parse, format, and compare version strings following the
SemVer 2 specification. See: https://semver.org
Updates #6466