Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static org.junit.Assert.*;
- import org.junit.Before;
- import org.junit.Test;
- public class JamManufacturerTest {
- private JamManufacturer j;
- @Before
- public void setUp() throws Exception {
- j = new JamManufacturer();
- }
- @Test
- public void test() {
- for (int jars = 0; jars < 500; jars++) {
- int nCartons = (jars + 11) / 12;
- int totalOunces = 21 * jars + 25 * nCartons;
- int lbs = (totalOunces + 15) / 16;
- double cost = 3.0 + 1.44 * nCartons + 0.96 * lbs;
- assertEquals(cost, j.computeShippingCost(jars), getTolerance(cost));
- }
- }
- /**
- *
- * @param cost
- * @return 5% tolerance for the cost
- */
- private double getTolerance(double cost) {
- return 0.05 * cost;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement