packages feed

naturalcomp-0.0.3: tests/colltest.hs

-- -*- coding: utf-8 -*-

import Data.List (sortBy)
import Test.HUnit
import Text.NaturalComp.Collation

-- from rfc5051 docs
a = "Abe Oeb abe abé oeb Ábe Äbe Ôeb ábe äbe ôeb"
b = "Abe abe abé Ábe ábe Äbe äbe Oeb oeb Ôeb ôeb"

sortTest f x y = assertEqual "" y $ unwords $ sortBy f $ words x

tests = TestList [ TestLabel "test1" $ TestCase $ sortTest naturalCollate a b
                 , TestLabel "test2" $ TestCase $ sortTest unicodeCollate a b ]

main = runTestTT tests