Skip to content

Commit

Permalink
Add some more Message tests
Browse files Browse the repository at this point in the history
Also changed the `SubString` test to actually use substrings with `@view`.
  • Loading branch information
JamesWrigley committed Jul 9, 2024
1 parent e5d75e9 commit 1fd0a68
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ end
@test !isopen(s2)
end

# Test all the send constructors
@testset "Message" begin
# Test all the send constructors
s1 = Socket(PUB)
s2 = Socket(SUB)
ZMQ.subscribe(s2, "")
Expand Down Expand Up @@ -170,7 +170,7 @@ end
@test String(ZMQ.recv(s2)) == str_msg

# Message(::SubString)
m4 = Message(str_msg[1:3])
m4 = Message(@view str_msg[1:3])
ZMQ.send(s1, m4)
@test String(ZMQ.recv(s2)) == str_msg[1:3]

Expand All @@ -187,8 +187,21 @@ end
ZMQ.send(s1, m6)
@test ZMQ.recv(s2) == buffer3

close(iobuf)
@test_throws ErrorException Message(iobuf)

close(s1)
close(s2)

# Test indexing
m = Message(10)
@test_throws BoundsError m[0]
@test_throws BoundsError m[11]

# Smoke tests
@test !Bool(m.more)
@test_throws ErrorException m.more = true
@test ZMQ.isfreed(m)
end

@testset "ZMQ resource management" begin
Expand Down

0 comments on commit 1fd0a68

Please sign in to comment.