def test_change(): assert change(0) == (0, 0, 0, 0) assert change(97) == (3, 2, 0, 2) assert change(8) == (0, 0, 1, 3) assert change(250) == (10, 0, 0, 0) assert change(144) == (5, 1, 1, 4) assert change(97) == (3, 2, 0, 2) assert change(100000000000) == (4000000000, 0, 0, 0) with pytest.raises(ValueError) as excinfo: change(-50) assert 'amount cannot be negative' == str(excinfo.value)
def test_change(self): """Test valid US change for a number of cents. Expected format: [quarter, dime, nickle, penny] """ self.assertEqual(change(97), (3, 2, 0, 2)) self.assertEqual(change(33.25), (1.0, 0.0, 1.0, 3.25)) self.assertEqual(change(8), (0, 0, 1, 3)) self.assertEqual(change(103), (4, 0, 0, 3)) self.assertEqual(change(0), (0, 0, 0, 0)) self.assertEqual(change(100000006), (4000000, 0, 1, 1)) self.assertRaises(ValueError, change, -1) self.assertRaises(TypeError, change, "foo")
def test_change_produces_correct_answers_for_small_values(self): self.assertEqual(change(97), (3, 2, 0, 2)) self.assertEqual(change(8), (0, 0, 1, 3)) self.assertEqual(change(250), (10, 0, 0, 0)) self.assertEqual(change(0), (0, 0, 0, 0)) self.assertEqual(change(41), (1, 1, 1, 1))
def test_change_handles_large_inputs(self): self.assertEqual(change(2500000000001), (100000000000, 0, 0, 1))
def test_change_produces_correct_answers_for_small_values(self): self.assertEqual(change(97), (3, 2, 0, 2)) self.assertEqual(change(8), (0, 0, 1, 3)) self.assertEqual(change(250), (10, 0, 0, 0)) self.assertEqual(change(0), (0, 0, 0, 0)) self.assertEqual(change(41), (1, 1, 1, 1))
def test_change_handles_large_inputs(self): self.assertEqual(change(2500000000001), (100000000000, 0, 0, 1))