Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Nov 24, 2023
1 parent 8bc4de0 commit f9f2abe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spec/std/char/reader_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ end

private def assert_reads_at_end(bytes, *, file = __FILE__, line = __LINE__)
str = String.new bytes
reader = Char::Reader.new(at_end: str)
reader = Char::Reader.new(str, pos: bytes.size)
reader.previous_char
reader.current_char.should eq(str[0]), file: file, line: line
reader.current_char_width.should eq(bytes.size), file: file, line: line
reader.pos.should eq(0), file: file, line: line
reader.error.should be_nil, file: file, line: line
end

private def assert_invalid_byte_sequence_at_end(bytes, *, file = __FILE__, line = __LINE__)
reader = Char::Reader.new(at_end: String.new bytes)
str = String.new bytes
reader = Char::Reader.new(str, pos: bytes.size)
reader.previous_char
reader.current_char.should eq(Char::REPLACEMENT), file: file, line: line
reader.current_char_width.should eq(1), file: file, line: line
reader.pos.should eq(bytes.size - 1), file: file, line: line
Expand Down Expand Up @@ -211,7 +214,7 @@ describe "Char::Reader" do
assert_invalid_byte_sequence Bytes[0xf4, 0x8f, 0xa0]
end

describe "#previous_char / at_end" do
describe "#previous_char" do
it "reads on valid UTF-8" do
assert_reads_at_end Bytes[0x00]
assert_reads_at_end Bytes[0x7f]
Expand Down

0 comments on commit f9f2abe

Please sign in to comment.