Skip to content

Commit

Permalink
Merge PR #64
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Jul 12, 2024
2 parents b59eb35 + 2601332 commit 9c190be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Data/IP/Addr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ ip4' checkTermination = do
_ <- char '.'
a3 <- octet
let as = [a0, a1, a2, a3]
skipSpaces
when checkTermination termination
when checkTermination $
skipSpaces >> termination
return as

skipSpaces :: Parser ()
Expand Down
5 changes: 4 additions & 1 deletion test/IPSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ data InvalidIPv4Str = Iv4 String deriving (Show)

instance Arbitrary InvalidIPv4Str where
arbitrary =
frequency [(9, arbitraryIIPv4Str arbitrary 32)
frequency [(8, arbitraryIIPv4Str arbitrary 32)
-- an IPv4 address should not end with a trailing `.`
,(1, Iv4 . (++ ".") . show <$> genIPv4)
-- an IPv4 address with mask should not include a white space
,(1, (\ip (NonNegative len) -> Iv4 (show ip ++ " /" ++ show (len :: Integer))) <$> genIPv4 <*> arbitrary)
]
where
genIPv4 :: Gen IPv4
Expand Down

0 comments on commit 9c190be

Please sign in to comment.