@@ -2,6 +2,7 @@ import Test.HUnit
2import RelationType
2import RelationType
3import Relation
3import Relation
4import RelationTuple
4import RelationTuple
5+import RelationTupleSet
5import qualified Data.Set as S
6import qualified Data.Set as S
6import qualified Data.Map as M
7import qualified Data.Map as M
7import qualified Data.HashSet as HS
8import qualified Data.HashSet as HS
@@ -49,6 +50,7 @@ validateAttrTypesMatchTupleAttrTypes rel@(Relation _ tupMapSet)
50simpleRel = case mkRelation attrs tupleSet of
51simpleRel = case mkRelation attrs tupleSet of
51 Right rel -> rel
52 Right rel -> rel
53+ Left err -> undefined
53 attrs = M.fromList [("a", Attribute "a" StringAtomType), ("b", Attribute "b" StringAtomType)]
55 attrs = M.fromList [("a", Attribute "a" StringAtomType), ("b", Attribute "b" StringAtomType)]
54 tupleSet = HS.fromList $ mkRelationTuples attrs [
56 tupleSet = HS.fromList $ mkRelationTuples attrs [
@@ -62,4 +64,11 @@ testRename1 = TestCase $ assertEqual "attribute invalid" (rename "a" "b" relatio
62testRename2 :: Test
64testRename2 :: Test
63testRename2 = TestCase $ assertEqual "attribute in use" (rename "b" "a" simpleRel) (Left $ RelationalError 1 "Attribute \"a\" already in use.")
65testRename2 = TestCase $ assertEqual "attribute in use" (rename "b" "a" simpleRel) (Left $ RelationalError 1 "Attribute \"a\" already in use.")
68+--test tupleset key mismatch failure
69+testMkRelation1 :: Test
70+testMkRelation1 = TestCase $ assertEqual "key mismatch" (mkRelation testAttrs testTupSet) (Left $ RelationalError 1 "Tuple values not of the same type for same keys")
72+ testAttrs = M.singleton "a" (Attribute "a" StringAtomType)
73+ testTupSet = HS.fromList [(RelationTuple (M.singleton "a" $ StringAtom "v")),
74+ RelationTuple (M.singleton "a" $ IntAtom 2)]