Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Function

testWriteSplatHeaderLimit

Private Function
std.Io.Writer.testWriteSplatHeaderLimit
fn testWriteSplatHeaderLimit(comptime test_case: SplatHeaderTestCase) !void

Params

File

Io/Writer.zig:324
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
fn testWriteSplatHeaderLimit(comptime test_case: SplatHeaderTestCase) !void {
    var buf: [test_case.buf_len]u8 = @splat(0);
    var aw: Allocating = if (test_case.writer_type == .allocating)
        try Allocating.initCapacity(testing.allocator, test_case.buf_len)
    else
        undefined;
    defer if (test_case.writer_type == .allocating) aw.deinit();
    var fw: Writer = if (test_case.writer_type == .fixed) .fixed(&buf) else undefined;
    var w: *Writer = switch (test_case.writer_type) {
        .allocating => &aw.writer,
        .fixed => &fw,
    };
    const n_or_error = w.writeSplatHeaderLimit(test_case.header, test_case.data, test_case.splat, .limited(test_case.limit));
    switch (test_case.expected_res) {
        .written => |expected_len| {
            const n = try n_or_error;
            try std.testing.expectEqual(expected_len, n);
        },
        .write_failed => {
            try std.testing.expectError(error.WriteFailed, n_or_error);
        },
    }
    try std.testing.expectEqualStrings(test_case.expected_buf_content, w.buffered());
}