diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 15:41:12 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 16:28:34 -0300 |
| commit | 18933ab34ea07f2cf755aa4e8d9bdb4dc25a67a6 (patch) | |
| tree | 9c2831a2ee8fef25364283151ca6ac312dc86ecf /addons/image | |
| parent | f34d3a74cc4a6b735c98ce98cef0df42bd065e67 (diff) | |
| download | pardes-18933ab34ea07f2cf755aa4e8d9bdb4dc25a67a6.tar.gz pardes-18933ab34ea07f2cf755aa4e8d9bdb4dc25a67a6.zip | |
the boundaries fuzzes and tests, failing first: bytes from outside (garbage and mutated-valid) into the reader that takes them, a fixed seed list and seconds, an error never a panic, memory held by a capped allocator (core/fuzz.zig, in core-test): 9P frames through the engine pardes runs (`runtime.ninep.Server(pardes.ctlfs, runtime.ninep.editor)`), framed as the engine frames them so that no walk reaches `os` (the host files) or `n`, the core effects dropped, a frame drawn after each push (16 seeds x 400 frames, deep: 607 writes, 604 reads in one run); a client inputs into the session reader (`replica.parseInput`, every tag decodeClient) applied with `update` and drawn; a session units recorded by an `Authority`, cut, flipped and grown, replayed by a `Replica` (the client road); a session byte dump and image, damaged, through `dump.check` and `dump.load`; and the sites the note found by reading, each a test: a +Search pane rows style past the syntax kinds (`m 1 1 0 0 0 0 0 3:0+3=7 a.txt`), a Grep row of a file named `a:5000000000:b` (core/Query.zig), a top-down BMP (its height negative, addons/image/image.zig, addon-test), an X10 mouse report with a control byte and an SGR one with button 192 (dev/tui/tui.zig, shell-test); on main (f34d3a74cc4a), Debug, each alone: the rows test `expected .err, found .ok` (drawn: `invalid enum value` at core/File.zig:2079), the session side `integer overflow` at core/draw.zig:282 (joinNotice, a prompt caret on a band of 65535 glyphs: Layer.capacity under a client row metrics), the client side `invalid enum value` at core/tape.zig:458 (`peek`), the Grep row `integer does not fit` at core/Query.zig:1267, the BMP `integer does not fit` (image.zig `info`), the X10 report `integer overflow` at vaxis Parser.zig:792; the 9P fuzz and the dump fuzz pass on main (no panic reached)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'addons/image')
| -rw-r--r-- | addons/image/image.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/addons/image/image.zig b/addons/image/image.zig index f2303433..48135458 100644 --- a/addons/image/image.zig +++ b/addons/image/image.zig @@ -137,3 +137,19 @@ test "a job decodes a picture to its size and pixels, and one past max_dim is sc try std.testing.expectEqual(8 + 1280 * 4, wide.len); try std.testing.expect(Image.jobRun("not a picture", arena.allocator()) == null); } + +test "a top-down BMP (its height negative in its header) opens at its size, as any picture" { + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + // 2x2, 24 bits, biHeight -2: rows top first, each 6 bytes and 2 of padding. + const bmp = "BM" ++ "\x46\x00\x00\x00" ++ "\x00\x00\x00\x00" ++ "\x36\x00\x00\x00" ++ + "\x28\x00\x00\x00" ++ "\x02\x00\x00\x00" ++ "\xfe\xff\xff\xff" ++ "\x01\x00" ++ "\x18\x00" ++ + "\x00\x00\x00\x00" ++ "\x10\x00\x00\x00" ++ "\x13\x0b\x00\x00" ++ "\x13\x0b\x00\x00" ++ "\x00\x00\x00\x00" ++ "\x00\x00\x00\x00" ++ + "\x00\x00\xff\x00\xff\x00\x00\x00" ++ "\xff\x00\x00\xff\xff\xff\x00\x00"; + try std.testing.expectEqual([2]u32{ 2, 2 }, info(bmp).?); + const got = Image.jobRun(bmp, arena.allocator()).?; + try std.testing.expectEqual(8 + 2 * 2 * 4, got.len); + try std.testing.expectEqual(2, std.mem.readInt(u32, got[4..8], .little)); + // Its first pixel is the top row's first: red (BGR 00 00 ff). + try std.testing.expectEqualSlices(u8, &.{ 0xff, 0, 0, 0xff }, got[8..12]); +} |
