File: Maptest.hs

package info (click to toggle)
missingh 1.6.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 688 kB
  • sloc: haskell: 5,472; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,098 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{-
Copyright (C) 2004-2011 John Goerzen <jgoerzen@complete.org>

All rights reserved.

For license and copyright information, see the file LICENSE
-}


module Maptest(tests) where
import Test.HUnit
import Data.Map.Utils
import Data.Map as M

test_flipM =
    let f inp exp = TestCase $ (M.fromList exp) @=? flipM (M.fromList inp) in
        [
         f ([]::[(Int,Int)]) ([]::[(Int,[Int])])
        ,f [("a", "b")] [("b", ["a"])]
        ,f [("a", "b"),
            ("c", "b"),
            ("d", "e"),
            ("b", "b")] [("b", ["c", "b", "a"]),
                         ("e", ["d"])]
        ]

test_flippedLookupM =
    let f item inp exp = TestCase $ exp @=? flippedLookupM item (M.fromList inp) in
        [
         f 'a' ([]::[(Char, Char)]) []
        ,f 'a' [("Test1", 'a'), ("Test2", 'b')] ["Test1"]
        ,f 'a' [("Test1", 'b'), ("Test2", 'b')] []
        ,f 'a' [("Test1", 'a'), ("Test2", 'a')] ["Test2", "Test1"]
        ]

tests = TestList [TestLabel "flipM" (TestList test_flipM),
                  TestLabel "flippedLookupM" (TestList test_flippedLookupM)
                 ]