Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gkappler/CombinedParsers.jl into …
Browse files Browse the repository at this point in the history
…vector_uint8
  • Loading branch information
gkappler committed Nov 5, 2020
2 parents 2af159a + 7f382a5 commit b35e372
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/CombinedParsers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ end
If available before end of sequence, parse `N` bytes successfully with `result_type` `T`, fail otherwise.
"""
Bytes(N::Integer, T::Type=Vector{UInt8}) = Bytes{T}(N)
_iterate(parser::Bytes, sequence, till, posi, next_i, state::Nothing) =
posi+parser.N <= till ? (nextind(sequence,posi,parser.N), MatchState()) : nothing
_iterate(parser::Bytes, sequence, till, posi, next_i, state::Nothing) =
posi+parser.N <= till+1 ? (nextind(sequence,posi,parser.N), MatchState()) : nothing
_iterate(parser::Bytes, sequence, till, posi, next_i, state::MatchState) =
nothing
regex_string_(x::Bytes{N}) where N = ".{$(N)}"
Expand Down
9 changes: 7 additions & 2 deletions test/test-parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ end
dat = 'a'^(new_Repeat_max)*'b';
@test String(parse(Repeat_stop('a','b';max=new_Repeat_max), dat))==dat[1:end-1]
end
end


@testset "Bytes" begin
# simple test for binary parsing
@test parse(Bytes(1,UInt8),[0x33]) == 0x33
@test parse(Bytes(2,UInt16),[0x33,0x66]) == 0x6633
@test parse(Bytes(4,Float32),[0x55,0x77,0x33,0x66]) == reinterpret(Float32,0x66337755)
end
end

@testset "FlatMap" begin
@test parse(
Expand Down

2 comments on commit b35e372

@gkappler
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/22384

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.5 -m "<description of version>" b35e372103fdf8b5e78e2a384b004c5a822e1c2c
git push origin v0.1.5

Please sign in to comment.