aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2023-01-06 21:35:45 +0100
committerJulien Dessaux2023-01-06 21:38:10 +0100
commit381126dccbde44931b13c79bed27e4f5d8d03577 (patch)
tree4470d0494ffdc8e4b7ebe401bda7b56bd2801d77
parentEnsure the pointer always ends up on an executable instruction for tui consis... (diff)
downloadzigfunge98-381126dccbde44931b13c79bed27e4f5d8d03577.tar.gz
zigfunge98-381126dccbde44931b13c79bed27e4f5d8d03577.tar.bz2
zigfunge98-381126dccbde44931b13c79bed27e4f5d8d03577.zip
Fixed #1: wrongful handling of \r newlines1.1
-rw-r--r--src/field.zig11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/field.zig b/src/field.zig
index 02bf544..ef5e6ea 100644
--- a/src/field.zig
+++ b/src/field.zig
@@ -283,7 +283,7 @@ pub const Field = struct {
lastIsCR = false;
switch (buffer[i]) {
'\n' => continue,
- else => return error.GOT_CR_WITHOUT_LF,
+ else => {},
}
}
switch (buffer[i]) {
@@ -322,7 +322,14 @@ pub const Field = struct {
try std.testing.expectEqual(f.load(cr2.reader()), error.FIELD_NOT_EMPTY);
var f2 = try Field.init(std.testing.allocator);
defer f2.deinit();
- try std.testing.expectEqual(f2.load(cr2.reader()), error.GOT_CR_WITHOUT_LF);
+ try f2.load(cr2.reader());
+ try std.testing.expectEqual(f2.x, 0);
+ try std.testing.expectEqual(f2.y, 0);
+ try std.testing.expectEqual(f2.lx, 1);
+ try std.testing.expectEqual(f2.lines.items.len, 2);
+ try std.testing.expectEqual(f2.lines.items[0].data.items[0], 'v');
+ try std.testing.expectEqual(f2.lines.items[1].x, 0);
+ try std.testing.expectEqual(f2.lines.items[1].data.items[0], '@');
}
pub fn set(f: *Field, x: i64, y: i64, v: i64) !void {
if (v == ' ') return f.blank(x, y);