Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

testParseOutput

cli.testParseOutput
fn testParseOutput(args: []const []const u8, expected_output: []const u8) !?Options

File

Code

fn testParseOutput(args: []const []const u8, expected_output: []const u8) !?Options {
    var diagnostics = Diagnostics.init(std.testing.allocator);
    defer diagnostics.deinit();

    var output: std.Io.Writer.Allocating = .init(std.testing.allocator);
    defer output.deinit();

    var options = parse(std.testing.allocator, std.testing.io, args, &diagnostics) catch |err| switch (err) {
        error.ParseError => {
            try diagnostics.renderToWriter(&output.writer, args);
            try std.testing.expectEqualStrings(expected_output, output.written());
            return null;
        },
        else => |e| return e,
    };
    errdefer options.deinit();

    try diagnostics.renderToWriter(&output.writer, args);
    try std.testing.expectEqualStrings(expected_output, output.written());
    return options;
}