Revision 256e28c4 htest/Test/Ganeti/Utils.hs

b/htest/Test/Ganeti/Utils.hs
31 31
import Test.QuickCheck hiding (Result)
32 32
import Test.HUnit
33 33

  
34
import Data.Char (isSpace)
34 35
import Data.List
35 36
import qualified Text.JSON as J
36 37

  
......
202 203
                                                    zip numbers names)
203 204
  ]
204 205

  
206
-- | Tests 'rstripSpace'.
207
prop_rStripSpace :: NonEmptyList Char -> Property
208
prop_rStripSpace (NonEmpty str) =
209
  forAll (resize 50 $ listOf1 (arbitrary `suchThat` isSpace)) $ \whitespace ->
210
  conjoin [ printTestCase "arb. string last char is not space" $
211
              case rStripSpace str of
212
                [] -> True
213
                xs -> not . isSpace $ last xs
214
          , printTestCase "whitespace suffix is stripped" $
215
              rStripSpace str ==? rStripSpace (str ++ whitespace)
216
          , printTestCase "whitespace reduced to null" $
217
              rStripSpace whitespace ==? ""
218
          , printTestCase "idempotent on empty strings" $
219
              rStripSpace "" ==? ""
220
          ]
221

  
205 222
-- | Test list for the Utils module.
206 223
testSuite "Utils"
207 224
            [ 'prop_commaJoinSplit
......
217 234
            , 'prop_niceSort_generic
218 235
            , 'prop_niceSort_numbers
219 236
            , 'prop_niceSortKey_equiv
237
            , 'prop_rStripSpace
220 238
            ]

Also available in: Unified diff