Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Jul 1, 2024
1 parent f925390 commit 101cbc0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/test/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -766,22 +766,22 @@ const Result = enum {
invalid,
};

const heap = std.heap;
const zstd = std.compress.zstd;

test "aegis128l - wycheproof" {
const alloc = std.testing.allocator;
var fbs = std.io.fixedBufferStream(@embedFile("wycheproof/aegis128L_test.json.zst"));
var window_buffer: [std.compress.zstd.DecompressorOptions.default_window_buffer_len]u8 = undefined;
var decompressor = std.compress.zstd.decompressor(
fbs.reader(),
.{ .window_buffer = &window_buffer },
);
var window_buffer: [zstd.DecompressorOptions.default_window_buffer_len]u8 = undefined;
var decompressor = zstd.decompressor(fbs.reader(), .{ .window_buffer = &window_buffer });
const json = try decompressor.reader().readAllAlloc(alloc, 1000000);
defer alloc.free(json);
const parsed = try std.json.parseFromSlice(JsonTests, alloc, json, .{ .ignore_unknown_fields = true });
defer parsed.deinit();
for (parsed.value.testGroups) |test_group| {
if (!std.mem.eql(u8, "AeadTest", test_group.type)) continue;
for (test_group.tests) |t| {
var arena = std.heap.ArenaAllocator.init(alloc);
var arena = heap.ArenaAllocator.init(alloc);
defer arena.deinit();
var arena_alloc = arena.allocator();
var key: [16]u8 = undefined;
Expand Down Expand Up @@ -813,19 +813,16 @@ test "aegis128l - wycheproof" {
test "aegis256 - wycheproof" {
const alloc = std.testing.allocator;
var fbs = std.io.fixedBufferStream(@embedFile("wycheproof/aegis256_test.json.zst"));
var window_buffer: [std.compress.zstd.DecompressorOptions.default_window_buffer_len]u8 = undefined;
var decompressor = std.compress.zstd.decompressor(
fbs.reader(),
.{ .window_buffer = &window_buffer },
);
var window_buffer: [zstd.DecompressorOptions.default_window_buffer_len]u8 = undefined;
var decompressor = zstd.decompressor(fbs.reader(), .{ .window_buffer = &window_buffer });
const json = try decompressor.reader().readAllAlloc(alloc, 1000000);
defer alloc.free(json);
const parsed = try std.json.parseFromSlice(JsonTests, alloc, json, .{ .ignore_unknown_fields = true });
defer parsed.deinit();
for (parsed.value.testGroups) |test_group| {
if (!std.mem.eql(u8, "AeadTest", test_group.type)) continue;
for (test_group.tests) |t| {
var arena = std.heap.ArenaAllocator.init(alloc);
var arena = heap.ArenaAllocator.init(alloc);
defer arena.deinit();
var arena_alloc = arena.allocator();
var key: [32]u8 = undefined;
Expand Down

0 comments on commit 101cbc0

Please sign in to comment.