diff --git a/Types/TrustLevel.hs b/Types/TrustLevel.hs index 83e4e5a5ea..27325cd2bf 100644 --- a/Types/TrustLevel.hs +++ b/Types/TrustLevel.hs @@ -10,6 +10,7 @@ module Types.TrustLevel ( TrustMap, readTrustLevel, showTrustLevel, + prop_read_show_TrustLevel ) where import qualified Data.Map as M @@ -17,7 +18,7 @@ import qualified Data.Map as M import Types.UUID data TrustLevel = Trusted | SemiTrusted | UnTrusted | DeadTrusted - deriving (Eq, Enum, Ord) + deriving (Eq, Enum, Ord, Bounded) type TrustMap = M.Map UUID TrustLevel @@ -33,3 +34,8 @@ showTrustLevel Trusted = "trusted" showTrustLevel UnTrusted = "untrusted" showTrustLevel SemiTrusted = "semitrusted" showTrustLevel DeadTrusted = "dead" + +prop_read_show_TrustLevel :: Bool +prop_read_show_TrustLevel = all check [minBound .. maxBound] + where + check l = readTrustLevel (showTrustLevel l) == Just l diff --git a/test.hs b/test.hs index 77cb0cd409..fb0cdfda58 100644 --- a/test.hs +++ b/test.hs @@ -31,6 +31,7 @@ import qualified Git.Filename import qualified Locations import qualified Types.KeySource import qualified Types.Backend +import qualified Types.TrustLevel import qualified Types import qualified GitAnnex import qualified Logs.UUIDBased @@ -118,6 +119,7 @@ quickcheck = TestLabel "quickcheck" $ TestList , qctest "prop_read_write_transferinfo" Logs.Transfer.prop_read_write_transferinfo , qctest "prop_read_show_direct" Annex.Content.Direct.prop_read_show_direct , qctest "prop_parse_show_log" Logs.Presence.prop_parse_show_log + , qctest "prop_read_show_TrustLevel" Types.TrustLevel.prop_read_show_TrustLevel ] blackbox :: Test