2012-11-26 15:11:37 +00:00
|
|
|
--------------------------------------------------------------------------------
|
2012-02-12 22:53:03 +00:00
|
|
|
module Hakyll.Core.Util.String.Tests
|
|
|
|
( tests
|
|
|
|
) where
|
|
|
|
|
|
|
|
|
2012-11-26 15:11:37 +00:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Test.Framework (Test, testGroup)
|
|
|
|
import Test.HUnit ((@=?))
|
2012-02-12 22:53:03 +00:00
|
|
|
|
2012-11-26 15:11:37 +00:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Hakyll.Core.Util.String
|
|
|
|
import TestSuite.Util
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
tests :: Test
|
|
|
|
tests = testGroup "Hakyll.Core.Util.String.Tests" $ concat
|
2012-02-12 22:53:03 +00:00
|
|
|
[ fromAssertions "trim"
|
|
|
|
[ "foo" @=? trim " foo\n\t "
|
|
|
|
]
|
|
|
|
|
|
|
|
, fromAssertions "replaceAll"
|
|
|
|
[ "32 & 131" @=? replaceAll "0x[0-9]+" (show . readInt) "0x20 & 0x83"
|
|
|
|
]
|
|
|
|
|
|
|
|
, fromAssertions "splitAll"
|
|
|
|
[ ["λ", "∀x.x", "hi"] @=? splitAll ", *" "λ, ∀x.x, hi"
|
|
|
|
]
|
2013-05-05 08:00:43 +00:00
|
|
|
|
|
|
|
, fromAssertions "needlePrefix"
|
|
|
|
[ "ab" @=? needlePrefix "cd" "abcde"
|
|
|
|
, "xx" @=? needlePrefix "ab" "xxab"
|
|
|
|
, "xx" @=? needlePrefix "a" "xx"
|
|
|
|
, "x" @=? needlePrefix "ab" "xabxab"
|
|
|
|
, "" @=? needlePrefix "ab" "abc"
|
|
|
|
, "" @=? needlePrefix "ab" "abab"
|
|
|
|
, "" @=? needlePrefix "" ""
|
|
|
|
]
|
2012-02-12 22:53:03 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
where
|
|
|
|
readInt :: String -> Int
|
|
|
|
readInt = read
|