Skip to content

Commit 7513315

Browse files
committed
-
1 parent 56b0671 commit 7513315

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

source_py3/test_python_toolbox/test_nifty_collections/test_bagging.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def test_sort(self):
250250
with cute_testing.RaiseAssertor(AttributeError):
251251
bag.sort()
252252

253-
def test_unsupported_operations(self):
253+
def test_operations_with_foreign_operands(self):
254254
bag = self.bag_type('meeeeow')
255255
with cute_testing.RaiseAssertor(TypeError): bag | 'foo'
256256
with cute_testing.RaiseAssertor(TypeError): 'foo' | bag
@@ -283,6 +283,25 @@ def test_unsupported_operations(self):
283283
with cute_testing.RaiseAssertor(TypeError): bag %= 'foo'
284284
with cute_testing.RaiseAssertor(TypeError): bag **= 'foo'
285285

286+
def test_operations(self):
287+
bag_0 = self.bag_type('abbccc')
288+
bag_1 = self.bag_type('bcc')
289+
bag_2 = self.bag_type('cddddd')
290+
assert bag_0 + bag_1 == self.bag_type('abbccc' + 'bcc')
291+
assert bag_1 + bag_0 == self.bag_type('bcc' + 'abbccc')
292+
assert bag_0 + bag_2 == self.bag_type('abbccc' + 'cddddd')
293+
assert bag_2 + bag_0 == self.bag_type('cddddd' + 'abbccc')
294+
assert bag_1 + bag_2 == self.bag_type('bcc' + 'cddddd')
295+
assert bag_2 + bag_1 == self.bag_type('cddddd' + 'bcc')
296+
297+
assert bag_0 - bag_1 == self.bag_type('abc')
298+
assert bag_1 - bag_0 == self.bag_type()
299+
assert bag_0 - bag_2 == self.bag_type('abbcc')
300+
assert bag_2 - bag_0 == self.bag_type('ddddd')
301+
assert bag_1 - bag_2 == self.bag_type('bc')
302+
assert bag_2 - bag_1 == self.bag_type('ddddd')
303+
304+
# blocktodo: continue for all operations
286305

287306

288307

0 commit comments

Comments
 (0)