1 -- | Miscellaneous functions for manipulating string.
7 import Test.Tasty ( TestTree, testGroup )
8 import Test.Tasty.HUnit ( (@?=), testCase )
11 -- | Takes a list of strings and numbers it like an ordered list.
15 -- >>> listify ["foo", "bar", "baz"]
16 -- ["1. foo","2. bar","3. baz"]
18 listify :: [String] -> [String]
20 zipWith (++) list_numbers
22 list_numbers = map show_with_dot [1::Integer ..]
23 show_with_dot x = (show x) ++ ". "
30 string_utils_tests :: TestTree
32 testGroup "StringUtils Tests" [ test_listify ]
34 test_listify :: TestTree
35 test_listify = testCase description $ actual @?= expected
37 description = "all items are numbered correctly"
38 actual = listify [ "item1", "item2" ]
39 expected = ["1. item1", "2. item2" ]