diff --git a/tests/test_TradeRoutines.py b/tests/test_TradeRoutines.py index d5e25b1..015bc0e 100644 --- a/tests/test_TradeRoutines.py +++ b/tests/test_TradeRoutines.py @@ -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!"