Revision e1ee7d5a htest/Test/Ganeti/TestCommon.hs
b/htest/Test/Ganeti/TestCommon.hs | ||
---|---|---|
174 | 174 |
getFields = do |
175 | 175 |
n <- choose (1, 32) |
176 | 176 |
vectorOf n getName |
177 |
|
|
178 |
-- | Generates a list of a given size with non-duplicate elements. |
|
179 |
genUniquesList :: (Eq a, Arbitrary a) => Int -> Gen [a] |
|
180 |
genUniquesList cnt = |
|
181 |
foldM (\lst _ -> do |
|
182 |
newelem <- arbitrary `suchThat` (`notElem` lst) |
|
183 |
return (newelem:lst)) [] [1..cnt] |
|
184 |
|
|
185 |
newtype SmallRatio = SmallRatio Double deriving Show |
|
186 |
instance Arbitrary SmallRatio where |
|
187 |
arbitrary = do |
|
188 |
v <- choose (0, 1) |
|
189 |
return $ SmallRatio v |
Also available in: Unified diff