def test_first_fit_few(self): h = rb.FirstFit(self.bins[:3]) expected = [[8, 2], [5, 4, 1], [7]] misfits = [6] self.assertEqual(len(self.items) - len(misfits), h.binpack(self.items)) did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part) self.assertEqual(misfits, h.misfits)
def test_first_fit_small(self): h = rb.FirstFit(make_bin=lambda: self.make_bin(7)) expected = [[5, 2], [7], [6, 1], [4]] misfits = [8] self.assertEqual(len(self.items) - len(misfits), h.binpack(self.items)) did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part) self.assertEqual(misfits, h.misfits)
def test_first_fit_make(self): h = rb.FirstFit(make_bin=lambda: self.make_bin(10)) self.assertEqual(len(self.items), h.binpack(self.items)) expected = [[8, 2], [5, 4, 1], [7], [6]] did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part)
def test_first_fit_fixed(self): h = rb.FirstFit(self.bins) self.assertEqual(len(self.items), h.binpack(self.items)) expected = [[8, 2], [5, 4, 1], [7], [6], []] did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part)