def test_weight_too_heavy(self): total_value, items = knapsack(self.n5, self.capacity5, self.weights5, self.values5) self.assertEqual(self.correctvalue5, total_value) self.assertEqual(self.correctitems5, items)
def test_simpleexample(self): total_value, items = knapsack(self.n4, self.capacity4, self.weights4, self.values4) self.assertEqual(self.correctvalue4, total_value) self.assertEqual(self.correctitems4, items)
def test_singleitem_value(self): total_value, items = knapsack(self.n2, self.capacity2, self.weights2, self.values2) self.assertEqual(self.correctvalue2, total_value) self.assertEqual(self.correctitems2, items)
def test_negativevalues(self): total_value, items = knapsack(self.n3, self.capacity3, self.weights3, self.values3) self.assertEqual(self.correctvalue3, total_value) self.assertEqual(self.correctitems3, items)
def test_noitems(self): total_value, items = knapsack(self.n1, self.capacity1, self.weights1, self.values1) self.assertEqual(self.correctvalue1, total_value) self.assertEqual(self.correctitems1, items)