+ where _types = def_value :: Integer
+
+-- | Test that functional if' behaves like the syntactic sugar if.
+prop_Utils_if'if :: Bool -> Int -> Int -> Bool
+prop_Utils_if'if cnd a b = Utils.if' cnd a b == if cnd then a else b
+
+-- | Test basic select functionality
+prop_Utils_select :: Int -- ^ Default result
+ -> [Int] -- ^ List of False values
+ -> [Int] -- ^ List of True values
+ -> Bool -- ^ Test result
+prop_Utils_select def lst1 lst2 =
+ Utils.select def cndlist == expectedresult
+ where expectedresult = Utils.if' (null lst2) def (head lst2)
+ flist = map (\e -> (False, e)) lst1
+ tlist = map (\e -> (True, e)) lst2
+ cndlist = flist ++ tlist
+
+-- | Test basic select functionality with undefined default
+prop_Utils_select_undefd :: [Int] -- ^ List of False values
+ -> NonEmptyList Int -- ^ List of True values
+ -> Bool -- ^ Test result
+prop_Utils_select_undefd lst1 (NonEmpty lst2) =
+ Utils.select undefined cndlist == head lst2
+ where flist = map (\e -> (False, e)) lst1
+ tlist = map (\e -> (True, e)) lst2
+ cndlist = flist ++ tlist
+
+-- | Test basic select functionality with undefined list values
+prop_Utils_select_undefv :: [Int] -- ^ List of False values
+ -> NonEmptyList Int -- ^ List of True values
+ -> Bool -- ^ Test result
+prop_Utils_select_undefv lst1 (NonEmpty lst2) =
+ Utils.select undefined cndlist == head lst2
+ where flist = map (\e -> (False, e)) lst1
+ tlist = map (\e -> (True, e)) lst2
+ cndlist = flist ++ tlist ++ [undefined]
+
+prop_Utils_parseUnit (NonNegative n) =
+ Utils.parseUnit (show n) == Types.Ok n &&
+ Utils.parseUnit (show n ++ "m") == Types.Ok n &&
+ (case Utils.parseUnit (show n ++ "M") of
+ Types.Ok m -> if n > 0
+ then m < n -- for positive values, X MB is less than X MiB
+ else m == 0 -- but for 0, 0 MB == 0 MiB
+ Types.Bad _ -> False) &&
+ Utils.parseUnit (show n ++ "g") == Types.Ok (n*1024) &&
+ Utils.parseUnit (show n ++ "t") == Types.Ok (n*1048576) &&
+ Types.isBad (Utils.parseUnit (show n ++ "x")::Types.Result Int)
+ where _types = (n::Int)
+
+-- | Test list for the Utils module.