summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-02-12 23:53:03 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-02-12 23:53:03 +0100
commite1fa778a78b64b5a49d0121b8c95af62d41ff7d6 (patch)
treed7a6138f8816b9391ad326fc0dd8e415ebff322b /tests
parent3c4dbd579993b0320bdc9440a916e0b64c79784d (diff)
downloadhakyll-e1fa778a78b64b5a49d0121b8c95af62d41ff7d6.tar.gz
Add some tests for Hakyll.Core.Util.String
Diffstat (limited to 'tests')
-rw-r--r--tests/Hakyll/Core/Util/String/Tests.hs28
-rw-r--r--tests/TestSuite.hs3
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/Hakyll/Core/Util/String/Tests.hs b/tests/Hakyll/Core/Util/String/Tests.hs
new file mode 100644
index 0000000..bbdfb96
--- /dev/null
+++ b/tests/Hakyll/Core/Util/String/Tests.hs
@@ -0,0 +1,28 @@
+module Hakyll.Core.Util.String.Tests
+ ( tests
+ ) where
+
+import Test.Framework (Test)
+import Test.HUnit ((@=?))
+
+import Hakyll.Core.Util.String
+import TestSuite.Util
+
+tests :: [Test]
+tests = concat
+ [ 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"
+ ]
+ ]
+
+ where
+ readInt :: String -> Int
+ readInt = read
diff --git a/tests/TestSuite.hs b/tests/TestSuite.hs
index d9ba854..70ebe98 100644
--- a/tests/TestSuite.hs
+++ b/tests/TestSuite.hs
@@ -9,6 +9,7 @@ import qualified Hakyll.Core.Rules.Tests
import qualified Hakyll.Core.Store.Tests
import qualified Hakyll.Core.UnixFilter.Tests
import qualified Hakyll.Core.Util.Arrow.Tests
+import qualified Hakyll.Core.Util.String.Tests
import qualified Hakyll.Web.Page.Tests
import qualified Hakyll.Web.Page.Metadata.Tests
import qualified Hakyll.Web.Template.Tests
@@ -32,6 +33,8 @@ main = defaultMain
Hakyll.Core.UnixFilter.Tests.tests
, testGroup "Hakyll.Core.Util.Arrow.Tests"
Hakyll.Core.Util.Arrow.Tests.tests
+ , testGroup "Hakyll.Core.Util.String.Tests"
+ Hakyll.Core.Util.String.Tests.tests
, testGroup "Hakyll.Web.Page.Tests"
Hakyll.Web.Page.Tests.tests
, testGroup "Hakyll.Web.Page.Metadata.Tests"