]> gitweb.michael.orlitzky.com - dead/halcyon.git/blob - src/StringUtils.hs
Use hyphens instead of underscores in access-token et al.
[dead/halcyon.git] / src / StringUtils.hs
1 -- |Miscellaneous functions for manipulating string.
2 module StringUtils
3 where
4
5 import Test.HUnit
6
7
8 -- | Takes a list of strings, call them string1, string2, etc. and
9 -- numbers them like a list. So,
10 --
11 -- 1. string1
12 -- 2. string2
13 -- 3. etc.
14 --
15 listify :: [String] -> [String]
16 listify =
17 zipWith (++) list_numbers
18 where
19 list_numbers = map show_with_dot [1::Integer ..]
20 show_with_dot x = (show x) ++ ". "
21
22
23
24 string_utils_tests :: [Test]
25 string_utils_tests = [ test_listify ]
26
27
28 test_listify :: Test
29 test_listify =
30 TestCase $ assertEqual description expected_items actual_items
31 where
32 description = "All items are numbered correctly."
33 actual_items = listify [ "item1", "item2" ]
34 expected_items = ["1. item1", "2. item2" ]