Skip to content

Commit cbd67cc

Browse files
committed
adding test cases.
1 parent d1f4ee6 commit cbd67cc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/Network/SocketSpec.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ spec = do
4040
{ addrFlags = [AI_PASSIVE]
4141
, addrSocketType = Stream
4242
}
43+
it "successfully binds to an ipv4 socket" $ do
44+
addr:_ <- getAddrInfo (Just hints) (Just serverAddr) Nothing
45+
sock <- socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr)
46+
bind sock $ addrAddress addr
47+
48+
it "fails to bind to unknown ipv4 socket" $ do
49+
addr:_ <- getAddrInfo (Just hints) (Just "127.0.0.3") Nothing
50+
sock <- socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr)
51+
bind sock (addrAddress addr) `shouldThrow` anyIOException
52+
4353
it "successfully binds to an ipv6 socket" $ do
4454
addr:_ <- getAddrInfo (Just hints) (Just serverAddr6) Nothing
4555
sock <- socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr)

0 commit comments

Comments
 (0)