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 standard library.
std › compress › flate › Decompress › testDecompress Private Function testDecompress Doc Source Private Function std.compress.flate.Decompress.testDecompress
fn testDecompress (container : Container , compressed : []const u8 , expected_plain : []const u8 ) !void Params container : Container compressed : []const u8 expected_plain : []const u8 File compress/flate/Decompress.zig: 1193
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222 fn testDecompress (container : Container , compressed : []const u8 , expected_plain : []const u8 ) !void {
var aw : std .Io .Writer .Allocating = .init (testing .allocator );
defer aw .deinit ();
// Decompress once using the normal methods.
{
var in : std .Io .Reader = .fixed (compressed );
var decompress : Decompress = .init (&in , container , &.{});
const decompressed_len = try decompress .reader .streamRemaining (&aw .writer );
try testing .expectEqual (expected_plain .len , decompressed_len );
try testing .expectEqualSlices (u8 , expected_plain , aw .written ());
}
// Decompress again by streaming one byte at a time to check that there aren't
// any problems with things like writing partial matches, etc.
aw .clearRetainingCapacity ();
{
var in : std .Io .Reader = .fixed (compressed );
var decompress : Decompress = .init (&in , container , &.{});
var decompressed_len : usize = 0 ;
while (true ) {
decompressed_len += decompress .reader .stream (&aw .writer , .limited (1 )) catch |err | switch (err ) {
error .EndOfStream => break ,
else => |e | return e ,
};
}
try testing .expectEqual (expected_plain .len , decompressed_len );
try testing .expectEqualSlices (u8 , expected_plain , aw .written ());
}
}