Skip to content

Commit c98340a

Browse files
committed
fix, simple tests
1 parent f274a5d commit c98340a

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/LNR.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ scannedindex(r::LineNumberingReader, i) = i < r.lines[end]
3434

3535
function Base.read(r::LineNumberingReader, ::Type{UInt8})
3636
c = read(r.io, UInt8)
37-
c == '\n' && !scannedindex(r, position(r)) && !eof(r) &&
37+
c == UInt8('\n') && !scannedindex(r, position(r)) && !eof(r) &&
3838
push!(r.lines, position(r)+1)
3939
return c
4040
end

test/runtests.jl

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
using LNR
2-
using Test
1+
using LNR, Test
32

4-
# write your own tests here
5-
@test 1 == 1
3+
@testset "LNR" begin
4+
io = IOBuffer("""
5+
lorem ipsum
6+
dolor sit amet
7+
consectetur adipiscing elit
8+
""") |> LineNumberingReader
9+
10+
@test cursor(io) == Cursor(1, 1)
11+
12+
@test readline(io) == "lorem ipsum"
13+
14+
@test cursor(io) == Cursor(2, 1)
15+
16+
seek(io, Cursor(1, 7))
17+
18+
@test read(io, Char) == 'i'
19+
20+
seek(io, Cursor(3, 13))
21+
22+
@test read(io, Char) == 'a'
23+
end

0 commit comments

Comments
 (0)