X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FStringUtils.hs;h=e498c2eea81cfc2025e2f3c546ecd519c0678832;hb=518f0ba7d66d93fdda2a5dd7b8ea90b59d874b27;hp=43e42646764c083ae2ddedac22a36b637709ba59;hpb=7bb00e04c15781d889f950d00babf3f183047bff;p=dead%2Fhalcyon.git diff --git a/src/StringUtils.hs b/src/StringUtils.hs index 43e4264..e498c2e 100644 --- a/src/StringUtils.hs +++ b/src/StringUtils.hs @@ -1,21 +1,19 @@ -- | Miscellaneous functions for manipulating string. module StringUtils ( listify, - string_utils_tests - ) + string_utils_tests ) where -import Test.Framework (Test, testGroup) -import Test.Framework.Providers.HUnit (testCase) -import Test.HUnit (Assertion, assertEqual) +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, +-- | Takes a list of strings and numbers it like an ordered list. -- --- 1. string1 --- 2. string2 --- 3. etc. +-- Examples: +-- +-- >>> listify ["foo", "bar", "baz"] +-- ["1. foo","2. bar","3. baz"] -- listify :: [String] -> [String] listify = @@ -26,19 +24,16 @@ listify = -- --- Tests +-- * Tests -- -test_listify :: Assertion -test_listify = - assertEqual description expected_items actual_items - where - description = "All items are numbered correctly." - actual_items = listify [ "item1", "item2" ] - expected_items = ["1. item1", "2. item2" ] - -string_utils_tests :: Test +string_utils_tests :: TestTree string_utils_tests = - testGroup "StringUtils Tests" [ tc1 ] + testGroup "StringUtils Tests" [ test_listify ] + +test_listify :: TestTree +test_listify = testCase description $ actual @?= expected where - tc1 = testCase "All items are numbered correctly." test_listify + description = "all items are numbered correctly" + actual = listify [ "item1", "item2" ] + expected = ["1. item1", "2. item2" ]