]> gitweb.michael.orlitzky.com - dead/halcyon.git/blobdiff - src/StringUtils.hs
Add a doctest suite.
[dead/halcyon.git] / src / StringUtils.hs
index f9d7dfc9cf8ae4b08c05f8f9dbd21ec52fac1230..a9e2625289c65be857d068f35a850e32009369ae 100644 (file)
@@ -1,9 +1,11 @@
--- |Miscellaneous functions for manipulating string.
-module StringUtils
+-- | Miscellaneous functions for manipulating string.
+module StringUtils (
+  listify,
+  string_utils_tests )
 where
 
-import Test.HUnit
-
+import Test.Tasty ( TestTree, testGroup )
+import Test.Tasty.HUnit ( (@?=), testCase )
 
 -- | Takes a list of strings, call them string1, string2, etc. and
 --   numbers them like a list. So,
@@ -13,21 +15,24 @@ import Test.HUnit
 --   3. etc.
 --
 listify :: [String] -> [String]
-listify items =
-    zipWith (++) list_numbers items
+listify =
+    zipWith (++) list_numbers
     where
       list_numbers = map show_with_dot [1::Integer ..]
       show_with_dot x = (show x) ++ ". "
 
 
+--
+-- Tests
+--
 
-string_utils_tests :: [Test]
-string_utils_tests = [ test_listify ]
-
+string_utils_tests :: TestTree
+string_utils_tests =
+  testGroup "StringUtils Tests" [ test_listify ]
 
-test_listify :: Test
-test_listify =
-    TestCase $ assertEqual "All items are numbered correctly." expected_items actual_items
-    where
-      actual_items = listify [ "item1", "item2" ]
-      expected_items = ["1. item1", "2. item2" ]
+test_listify :: TestTree
+test_listify = testCase description $ actual @?= expected
+  where
+    description = "all items are numbered correctly"
+    actual = listify [ "item1", "item2" ]
+    expected = ["1. item1", "2. item2" ]