Revision 0b288282 htest/Test/Ganeti/OpCodes.hs

b/htest/Test/Ganeti/OpCodes.hs
386 386
genFieldsNE :: Gen [NonEmptyString]
387 387
genFieldsNE = genFields >>= mapM mkNonEmpty
388 388

  
389
-- | Generate an arbitrary IPv4 address in textual form.
390
genIp4Addr :: Gen NonEmptyString
391
genIp4Addr = do
392
  a <- choose (1::Int, 255)
393
  b <- choose (0::Int, 255)
394
  c <- choose (0::Int, 255)
395
  d <- choose (0::Int, 255)
396
  mkNonEmpty $ intercalate "." (map show [a, b, c, d])
397

  
398
-- | Generate an arbitrary IPv4 network address in textual form.
399
genIp4Net :: Gen NonEmptyString
400
genIp4Net = do
401
  netmask <- choose (8::Int, 30)
402
  ip <- genIp4Addr
403
  mkNonEmpty $ fromNonEmpty ip ++ "/" ++ show netmask
404

  
405 389
-- | Generate a 3-byte MAC prefix.
406 390
genMacPrefix :: Gen NonEmptyString
407 391
genMacPrefix = do

Also available in: Unified diff