summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"