Something went wrong. Try again.
Brotli (RFC 7932) compression and decompression for Zig 0.17, with sans-I/O streaming cores and std.Io adapters.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
//! The shape of a case in `synth.zig`.
const std = @import("std");
pub const Piece = union(enum) { text: []const u8, repeat: struct { count: usize, pattern: []const u8 },};
pub const Case = struct { name: []const u8, /// Whether a decoder must accept the stream. ok: bool, /// The reference implementation skips this case. The only one is a /// valid stream followed by junk, which its Go decoder rejects; this /// decoder stops at the end of the stream, as it should, and leaves the /// junk unread. skipped_upstream: bool = false, compressed: []const u8, /// What it decodes to, when it is accepted. output: []const Piece,
/// The expected output, assembled from its pieces. pub fn expected(c: Case, gpa: std.mem.Allocator) ![]u8 { var out: std.ArrayList(u8) = .empty; errdefer out.deinit(gpa); for (c.output) |p| switch (p) { .text => |t| try out.appendSlice(gpa, t), .repeat => |r| for (0..r.count) |_| try out.appendSlice(gpa, r.pattern), }; return out.toOwnedSlice(gpa); }};