add passing test for blank lines
All checks were successful
Generic zig build / build (push) Successful in 21s
All checks were successful
Generic zig build / build (push) Successful in 21s
This commit is contained in:
parent
353f8bca35
commit
390b2f3a23
1 changed files with 30 additions and 0 deletions
30
src/srf.zig
30
src/srf.zig
|
|
@ -1740,6 +1740,36 @@ test "conversion from string true/false to proper type" {
|
||||||
try std.testing.expect(!rec2.b);
|
try std.testing.expect(!rec2.b);
|
||||||
try std.testing.expectError(error.StringValueOfBooleanMustBetrueOrfalse, parsed.records[2].to(Data));
|
try std.testing.expectError(error.StringValueOfBooleanMustBetrueOrfalse, parsed.records[2].to(Data));
|
||||||
}
|
}
|
||||||
|
test "iterator with blank" {
|
||||||
|
const Data = struct {
|
||||||
|
foo: []const u8,
|
||||||
|
bar: u8,
|
||||||
|
qux: ?TestRecType = .foo,
|
||||||
|
b: bool = false,
|
||||||
|
f: f32 = 4.2,
|
||||||
|
custom: ?TestCustomType = null,
|
||||||
|
};
|
||||||
|
const compact =
|
||||||
|
\\#!srfv1
|
||||||
|
\\foo::1,bar:num:42
|
||||||
|
\\
|
||||||
|
\\# second record
|
||||||
|
\\
|
||||||
|
\\foo::2,bar:num:24
|
||||||
|
\\
|
||||||
|
;
|
||||||
|
// Round trip and make sure we get equivalent objects back
|
||||||
|
var compact_reader = std.Io.Reader.fixed(compact);
|
||||||
|
const parsed = try parse(&compact_reader, std.testing.allocator, .{});
|
||||||
|
defer parsed.deinit();
|
||||||
|
|
||||||
|
const rec1 = try parsed.records[0].to(Data);
|
||||||
|
try std.testing.expectEqual('1', rec1.foo[0]);
|
||||||
|
try std.testing.expectEqual(@as(u8, 42), rec1.bar);
|
||||||
|
const rec2 = try parsed.records[1].to(Data);
|
||||||
|
try std.testing.expectEqual('2', rec2.foo[0]);
|
||||||
|
try std.testing.expectEqual(@as(u8, 24), rec2.bar);
|
||||||
|
}
|
||||||
test "unions" {
|
test "unions" {
|
||||||
const Foo = struct {
|
const Foo = struct {
|
||||||
number: u8,
|
number: u8,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue