Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- macOS-14
arch:
- x64
- x86 # Test
- aarch64
exclude:
- os: ubuntu-latest
Expand All @@ -37,6 +38,10 @@ jobs:
arch: x64
- os: macOS-14
version: '1.6'
- os: macOS-14
arch: x86
- os: macOS-13
arch: x86
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
Expand Down
2 changes: 1 addition & 1 deletion src/codec/Codecs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ProtoDecoder(io::IO) = ProtoDecoder(io, eof)

struct LengthDelimitedProtoDecoder{I<:IO} <: AbstractProtoDecoder
io::I
endpos::Int
endpos::Int64
end
message_done(d::LengthDelimitedProtoDecoder) = d.endpos == position(d.io)

Expand Down
1 change: 1 addition & 0 deletions src/codec/decode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ end
function decode(d::AbstractProtoDecoder, ::Type{Ref{T}}) where {T}
bytelen = vbyte_decode(d.io, UInt32)
endpos = bytelen + position(d.io)
endpos = convert(Int64, endpos)
out = decode(LengthDelimitedProtoDecoder(d.io, endpos), T)
@assert position(d.io) == endpos
return out
Expand Down
4 changes: 2 additions & 2 deletions test/test_perf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ vbyte_decode(io, UInt64)

@test_noalloc vbyte_encode(io, typemax(UInt32))
seekstart(io)
@test @allocated(vbyte_decode(io, UInt32)) == 16
@test @allocated(vbyte_decode(io, UInt32)) <= 16 # 32 Bit systems require fewer allocations
@test_noalloc vbyte_encode(io, typemax(UInt64))
seekstart(io)
@test @allocated(vbyte_decode(io, UInt64)) == 16
@test @allocated(vbyte_decode(io, UInt64)) <= 16 # 32 Bit systems require fewer allocations

@enumx TestEnum DEFAULT=0 OTHER=1

Expand Down
16 changes: 8 additions & 8 deletions test/test_protojl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ end
typemax(UInt32),
typemax(UInt64),
EmptyMessage(),
NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, 1), nothing), OneOf(:y, 2), nothing),
NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, Int64(1)), nothing), OneOf(:y, Int64(2)), nothing),
OneOf(:oneof_uint32_field, typemax(UInt32)),

[UInt8[0xff]],
Expand All @@ -206,8 +206,8 @@ end
[typemax(UInt64)],
[EmptyMessage()],
[
NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, 3), nothing), OneOf(:y, 4), nothing),
NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, 3), nothing), OneOf(:y, 4), CoRecursiveMessage(nothing)),
NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, Int64(3)), nothing), OneOf(:y, Int64(4)), nothing),
NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, Int64(3)), nothing), OneOf(:y, Int64(4)), CoRecursiveMessage(nothing)),
],

Dict("K" => UInt8[0xff]),
Expand All @@ -226,8 +226,8 @@ end
Dict("K" => typemax(UInt64)),
Dict("K" => EmptyMessage()),
Dict(
"K1" => NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, 5), nothing), OneOf(:y, 6), nothing),
"K2" => NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, 5), nothing), OneOf(:y, 6), CoRecursiveMessage(nothing)),
"K1" => NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, Int64(5)), nothing), OneOf(:y, Int64(6)), nothing),
"K2" => NonEmptyMessage(typemax(UInt32), NonEmptyMessage(typemax(UInt32), nothing, OneOf(:y, Int64(5)), nothing), OneOf(:y, Int64(6)), CoRecursiveMessage(nothing)),

),

Expand Down Expand Up @@ -302,9 +302,9 @@ using ProtoBuf
end

test_dictionary = Dict{String, Int64}(
"field1"=>1,
"field2"=>-5,
"field3"=>120,
"field1"=>Int64(1),
"field2"=>Int64(-5),
"field3"=>Int64(120),
)

dict_message = Map(test_dictionary)
Expand Down
Loading