diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-03-10 18:44:30 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-03-10 18:44:30 -0400 |
| commit | 18f1fef1426cb0405c733890b2e1d8d48627e4fe (patch) | |
| tree | f019a3291b74a42206691a75e2832802bb50abc7 /lib/std/buffer.zig | |
| parent | b6fbd524f122449e6e2bb4d73ce3f59b01286f50 (diff) | |
| download | zig-18f1fef1426cb0405c733890b2e1d8d48627e4fe.tar.gz zig-18f1fef1426cb0405c733890b2e1d8d48627e4fe.zip | |
update standard library to new I/O streams API
Diffstat (limited to 'lib/std/buffer.zig')
| -rw-r--r-- | lib/std/buffer.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/std/buffer.zig b/lib/std/buffer.zig index a33670b6d3..28ce2a5610 100644 --- a/lib/std/buffer.zig +++ b/lib/std/buffer.zig @@ -219,3 +219,15 @@ test "Buffer.print" { try buf.print("Hello {} the {}", .{ 2, "world" }); testing.expect(buf.eql("Hello 2 the world")); } + +test "Buffer.outStream" { + var buffer = try Buffer.initSize(testing.allocator, 0); + defer buffer.deinit(); + const buf_stream = buffer.outStream(); + + const x: i32 = 42; + const y: i32 = 1234; + try buf_stream.print("x: {}\ny: {}\n", .{ x, y }); + + testing.expect(mem.eql(u8, buffer.toSlice(), "x: 42\ny: 1234\n")); +} |
