Skip to content

Commit

Permalink
#106 unit-test forSeparateByEqualParts() method was implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim55667757 committed Dec 3, 2022
1 parent 5b54f1c commit efe0949
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_TradeRoutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,24 @@ def test_UpdateClassFieldsPositive(self):
for test in testData:
TradeRoutines.UpdateClassFields(testClass, test)
assert testClass.a == test["a"] and testClass.b == test["b"] and testClass.c == test["c"], "Incorrect output!"

def test_SeparateByEqualPartsCheckType(self):
assert isinstance(TradeRoutines.SeparateByEqualParts(elements=[], parts=2, union=True), list), "Not list type returned!"

def test_SeparateByEqualPartsPositive(self):
testData = [
(None, 0, True, []), (None, 0, False, []), ([], 0, True, []), ([], 0, False, []),
([1], 1, True, [[1]]), ([1], 1, False, [[1]]),
([1], 2, True, [[1]]), ([1], 2, False, [[1], []]),
([1, 2, 3], 4, True, [[1], [2], [3]]), ([1, 2, 3], 4, False, [[1], [2], [3], []]),
([1, 2, 3], 5, True, [[1], [2], [3]]), ([1, 2, 3], 5, False, [[1], [2], [3], [], []]),
([1, 2, 3], 3, True, [[1], [2], [3]]), ([1, 2, 3], 3, False, [[1], [2], [3]]),
([1, 2, 3], 2, True, [[1], [2, 3]]), ([1, 2, 3], 2, False, [[1], [2], [3]]),
([1, 2, 3], 1, True, [[1, 2, 3]]), ([1, 2, 3], 1, False, [[1, 2, 3]]),
([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2, True, [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]),
([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2, True, [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10]]),
([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2, False, [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10]]),
]

for test in testData:
assert TradeRoutines.SeparateByEqualParts(elements=test[0], parts=test[1], union=test[2]) == test[3], "Incorrect output!"

0 comments on commit efe0949

Please # to comment.