Skip to content

Commit 8869921

Browse files
committed
fix show bug, tests for type conversions and show
1 parent c553c9f commit 8869921

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/show.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222

2323
function show(io::IO, f::TAMQPFieldValuePair)
2424
indent = isa(io, IOContext) ? get(io, :indent, "") : ""
25-
print(indent)
25+
print(io, indent)
2626
show(io, f.name)
2727
print(io, " => ")
2828
show(io, f.val)
@@ -52,7 +52,7 @@ function show(io::IO, fields::Vector{Pair{Symbol,TAMQPField}})
5252
idx = 1
5353
for fld in fields
5454
(idx > 1) && print(ioc, '\n')
55-
print(indent)
55+
print(ioc, indent)
5656
show(ioc, fld.first)
5757
print(ioc, " => ")
5858
show(ioc, fld.second)

test/test_coverage.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ testlog(msg) = println(msg)
1212

1313
function runtests(;virtualhost="/", host="localhost", port=AMQPClient.AMQP_DEFAULT_PORT, auth_params=AMQPClient.DEFAULT_AUTH_PARAMS)
1414
verify_spec()
15+
test_types()
1516
@test default_exchange_name("direct") == "amq.direct"
1617
@test default_exchange_name() == ""
1718
@test AMQPClient.method_name(AMQPClient.TAMQPMethodPayload(:Basic, :Ack, (1, false))) == "Basic.Ack"
@@ -180,4 +181,25 @@ function verify_spec()
180181
end
181182
end
182183

184+
function test_types()
185+
d = Dict{String,Any}(
186+
"bool" => 0x1,
187+
"int" => 10,
188+
"uint" => 0x1,
189+
"float" => rand(),
190+
"shortstr" => convert(AMQPClient.TAMQPShortStr, randstring(10)),
191+
"longstr" => convert(AMQPClient.TAMQPLongStr, randstring(1024)))
192+
ft = convert(AMQPClient.TAMQPFieldTable, d)
193+
iob = IOBuffer()
194+
show(iob, ft)
195+
@test length(take!(iob)) > 0
196+
197+
fields = [Pair{Symbol,AMQPClient.TAMQPField}(:bit, AMQPClient.TAMQPBit(0x1)),
198+
Pair{Symbol,AMQPClient.TAMQPField}(:shortstr, convert(AMQPClient.TAMQPShortStr, randstring(10))),
199+
Pair{Symbol,AMQPClient.TAMQPField}(:longstr, convert(AMQPClient.TAMQPLongStr, randstring(1024))),
200+
Pair{Symbol,AMQPClient.TAMQPField}(:fieldtable, ft)]
201+
show(iob, fields)
202+
@test length(take!(iob)) > 0
203+
end
204+
183205
end # module AMQPTestCoverage

0 commit comments

Comments
 (0)