% $Id: SetOpsTest.oz,v 1.3 2012/01/03 15:20:19 leavens Exp $ \insert 'SetOps.oz' \insert 'TestingNoStop.oz' {StartTesting 'SetOpsTest $Revision: 1.3 $'} {StartTesting 'AsSet'} {Assert {Equal {AsSet nil} {EmptySet}}} {Assert {Equal {AsSet [1 2 3]} {AsSet [3 1 2]}}} {Assert {Not {Equal {AsSet [1 2 3]} {AsSet [1 2]}}}} {Assert {Not {Equal {AsSet [c b]} {AsSet [a b c]}}}} {StartTesting 'AsList'} {Assert {AsList {EmptySet}} == nil} declare MyList = {AsList {AsSet [1 2 3]}} {Assert {Member 1 MyList}} {Assert {Member 2 MyList}} {Assert {Member 3 MyList}} {Assert {Length MyList} == 3} {StartTesting 'Add'} {Assert {Equal {Add {EmptySet} 1} {AsSet [1]}}} {Assert {Equal {Add {AsSet [2 3]} 1} {AsSet [1 2 3]}}} {Assert {Equal {Add {AsSet [2 3 1]} 1} {AsSet [2 1 3]}}} {StartTesting 'Remove'} {Assert {Equal {Remove {EmptySet} 7} {EmptySet}}} {Assert {Equal {Remove {AsSet [2 3 1]} 1} {AsSet [3 2]}}} {Assert {Equal {Remove {AsSet [2 3 1 5 7 4]} 5} {AsSet [3 2 1 7 4]}}} {Assert {Equal {Remove {AsSet [2 3 4 8]} 1} {AsSet [2 3 4 8]}}} {StartTesting 'Union'} {Assert {Equal {Union {EmptySet} {AsSet [d e]}} {AsSet [d e]}}} {Assert {Equal {Union {AsSet [a b c]} {EmptySet}} {AsSet [a b c]}}} {Assert {Equal {Union {AsSet [a b c]} {AsSet [d e]}} {AsSet [a b c d e]}}} {Assert {Equal {Union {AsSet [e a b c]} {AsSet [c d e a]}} {AsSet [a b c d e]}}} {StartTesting 'Minus'} {Assert {Equal {Minus {EmptySet} {AsSet [d e]}} {EmptySet}}} {Assert {Equal {Minus {AsSet [d e]} {EmptySet}} {AsSet [d e]}}} {Assert {Equal {Minus {AsSet [a b c]} {AsSet [d e]}} {AsSet [a b c]}}} {Assert {Equal {Minus {AsSet [e a b c]} {AsSet [c d a e]}} {AsSet [b]}}} {Assert {Equal {Minus {AsSet [e a b c]} {AsSet [c e d a f]}} {AsSet [b]}}} {Assert {Equal {Minus {AsSet [a b]} {AsSet [b a]}} {AsSet nil}}} {StartTesting 'Intersect'} {Assert {Equal {Intersect {EmptySet} {AsSet [d e]}} {EmptySet}}} {Assert {Equal {Intersect {AsSet [a b c]} {AsSet [d e]}} {EmptySet}}} {Assert {Equal {Intersect {AsSet [e a b c]} {AsSet [c d a e]}} {AsSet [a e c]}}} {Assert {Equal {Intersect {AsSet [e a b c]} {AsSet [c e d a f b]}} {AsSet [c b a e]}}} {Assert {Equal {Intersect {AsSet [a b]} {AsSet [b a]}} {AsSet [a b]}}} {StartTesting 'UnionList'} {Assert {Equal {UnionList nil} {EmptySet}}} {Assert {Equal {UnionList [{AsSet [a b c]} {AsSet nil} {AsSet [d e]}]} {AsSet [a b c d e]}}} {Assert {Equal {UnionList [{AsSet [a]} {AsSet [b c]} {EmptySet} {AsSet [d e]} {AsSet [f g h i j]} {AsSet [k l m a b e]}]} {AsSet [a b c d e f g h i j k l m]}}} {DoneTesting}