Skip to content

std.Io.takeDelimiter tosses too many characters #25132

@pancelor

Description

@pancelor

Zig Version

0.16.0-dev.164+bc7955306

Steps to Reproduce and Observed Behavior

This test fails:

const std = @import("std");
test {
    var r: std.Io.Reader = .fixed("abc\ndef");

    try std.testing.expectEqualStrings("abc", try r.takeDelimiter('\n') orelse "null");
    try std.testing.expectEqualStrings("def", try r.takeDelimiter('\n') orelse "null");
    try std.testing.expectEqual(null, r.takeDelimiter('\n'));
}

Result of zig build test:

error: 'main.test_0' failed: ====== expected this output: =========
def␃

======== instead found this: =========
ef␃

Expected Behavior

The test should pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions