def test_batch_3(self): # More complex cases inp = (13, 2, 3, 4, 3, 1, 1, 1, 4, 2, 3) size = 5 expect = [[13], [2, 3], [4, 3], [1, 1, 1, 4], [2, 3]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result) inp = (6, 5, 6, 8, 6) size = 7 expect = [[6, 5], [6, 8], [6]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result) inp = tuple(range(1, 15)) size = 7 expect = [[1, 2, 3, 4], [5, 6], [7], [8], [9], [10], [11], [12], [13], [14]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result) inp = (1, 8, 3, 4, 3, 2, 4, 2, 3, 4, 2, 8, 8, 1, 1, 1, 18) size = 8 expect = [[1, 8], [3, 4, 3], [2, 4, 2], [3, 4, 2], [8], [8], [1, 1, 1, 18]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result) size = 4 expect = [[1, 8], [3, 4], [3, 2], [4], [2, 3], [4], [2, 8], [8], [1, 1, 1, 18]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result)
def test_batch_5(self): big = 20000 inp = (1, 3, 5, 9) * big size = 10 result = quiz_resubmit.batch(inp, size) self.assertEqual(big, len(result)) for elt in result: self.assertEqual([1, 3, 5, 9], elt)
def test_batch_4(self): big = 20000 inp = (9, 9, 9, 9, 9) * big size = 10 result = quiz_resubmit.batch(inp, size) self.assertEqual(big * 5 / 2, len(result)) for elt in result: self.assertEqual([9, 9], elt)
def test_batch_2(self): # Batch fills/overflows inp = (1, 2, 3) size = 4 expect = [[1, 2, 3]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result) inp = (4, 4) size = 5 expect = [[4, 4]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result) inp = (4, 4, 4) size = 5 expect = [[4, 4], [4]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result)
def test_batch_1(self): # Simple cases inp = (9, ) size = 4 expect = [[9]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result) inp = (1, 2) size = 4 expect = [[1, 2]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result) inp = (4, 4) size = 4 expect = [[4], [4]] result = quiz_resubmit.batch(inp, size) self.assertEqual(expect, result)