on master help sign in
Add some tests for Hakyll.Core.Util.String
commite1fa778a78b64b5a49d0121b8c95af62d41ff7d6 authorJasper Van der Jeugt <m@jaspervdj.be> dateSun 12 Feb 2012, 23:53 (15 years ago) parent3c4dbd5
2 files changed+31
tests/Hakyll/Core/Util/String/Tests.hs+28 tests/TestSuite.hs+3
tests/Hakyll/Core/Util/String/Tests.hsnew file+28
@@ -0,0 +1,28 @@
1+module Hakyll.Core.Util.String.Tests
2+ ( tests
3+ ) where
4+
5+import Test.Framework (Test)
6+import Test.HUnit ((@=?))
7+
8+import Hakyll.Core.Util.String
9+import TestSuite.Util
10+
11+tests :: [Test]
12+tests = concat
13+ [ fromAssertions "trim"
14+ [ "foo" @=? trim " foo\n\t "
15+ ]
16+
17+ , fromAssertions "replaceAll"
18+ [ "32 & 131" @=? replaceAll "0x[0-9]+" (show . readInt) "0x20 & 0x83"
19+ ]
20+
21+ , fromAssertions "splitAll"
22+ [ ["λ", "∀x.x", "hi"] @=? splitAll ", *" "λ, ∀x.x, hi"
23+ ]
24+ ]
25+
26+ where
27+ readInt :: String -> Int
28+ readInt = read
tests/TestSuite.hs+3
@@ -9,6 +9,7 @@ import qualified Hakyll.Core.Rules.Tests
99import qualified Hakyll.Core.Store.Tests
1010import qualified Hakyll.Core.UnixFilter.Tests
1111import qualified Hakyll.Core.Util.Arrow.Tests
12+import qualified Hakyll.Core.Util.String.Tests
1213import qualified Hakyll.Web.Page.Tests
1314import qualified Hakyll.Web.Page.Metadata.Tests
1415import qualified Hakyll.Web.Template.Tests
@@ -32,6 +33,8 @@ main = defaultMain
3233 Hakyll.Core.UnixFilter.Tests.tests
3334 , testGroup "Hakyll.Core.Util.Arrow.Tests"
3435 Hakyll.Core.Util.Arrow.Tests.tests
36+ , testGroup "Hakyll.Core.Util.String.Tests"
37+ Hakyll.Core.Util.String.Tests.tests
3538 , testGroup "Hakyll.Web.Page.Tests"
3639 Hakyll.Web.Page.Tests.tests
3740 , testGroup "Hakyll.Web.Page.Metadata.Tests"