File tree Expand file tree Collapse file tree 1 file changed +35
-2
lines changed Expand file tree Collapse file tree 1 file changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,40 @@ tests.test("basics") {
83
83
expectEqual ( [ . Satchel, . Box] , p)
84
84
}
85
85
86
- // FIXME: add tests for all of SetAlgebra, in particular
87
- // insert/remove/replace.
86
+ tests. test ( " set algebra " ) {
87
+ typealias P = PackagingOptions
88
+
89
+ // remove
90
+ var p = P . BoxOrBag
91
+ expectNil ( p. remove ( P . Carton) )
92
+
93
+ p = P . BoxOrBag
94
+ p. remove ( P . BoxOrCartonOrBag)
95
+ expectEqual ( P ( ) , p)
96
+
97
+ p = P . BoxOrBag
98
+ expectEqual ( P . Bag, p. remove ( P . SatchelOrBag) )
99
+ expectEqual ( P . Box, p)
100
+
101
+ // insert
102
+ p = P . Box
103
+ var insertionResult = p. insert ( . Bag)
104
+ expectTrue ( insertionResult. inserted)
105
+ expectEqual ( P . Bag, insertionResult. memberAfterInsert)
106
+ expectEqual ( P . BoxOrBag, p)
107
+
108
+ insertionResult = p. insert ( . Bag)
109
+ expectFalse ( insertionResult. inserted)
110
+ expectEqual ( P . Bag, insertionResult. memberAfterInsert)
111
+
112
+ // update
113
+ p = P . Box
114
+ expectNil ( p. update ( with: . Bag) )
115
+ expectEqual ( P . BoxOrBag, p)
116
+
117
+ p = P . Box
118
+ expectEqual ( P . Box, p. update ( with: . BoxOrBag) )
119
+ expectEqual ( P . BoxOrBag, p)
120
+ }
88
121
89
122
runAllTests ( )
You can’t perform that action at this time.
0 commit comments