package hw2;

/**
 * A driver that can be used to test the Pricer class.
 * 
 * @author CS159 Professors
 * @version 1
 */
public class PricerTest {

	/**
	 * The entry point of the driver.
	 * 
	 * @param args The command-line arguments (which are ignored)
	 */
	public static void main(String[] args) {

		double tolerance = 0.01;
		String description;
		Pricer popperPricer, wingPricer;
		
		
		// Tests for wings
		
		wingPricer = new Pricer(5, 7.49, 1.80);
		
		int[] wings = {-30, 0, 3, 5, 7, 12, 13, 23, 36, 98};
		
		System.out.println("Tests that were Failed:");

		System.out.println("");
		int[] expectedFullBoxes = {0, 0, 0, 1, 1, 2, 2, 4, 7, 19};
		for (int i=0; i<wings.length; i++) {
			description = String.format("wingPricer.numberOfFullBoxes(%d)", wings[i]);
			Test.forEqualInts(expectedFullBoxes[i], wingPricer.numberOfFullBoxes(wings[i]), description);
		}

		System.out.println("");
		int[] expectedExtras = {0, 0, 3, 0, 2, 2, 3, 3, 1, 3};
		for (int i=0; i<wings.length; i++) {
			description = String.format("wingPricer.numberOfExtras(%d)", wings[i]);
			Test.forEqualInts(expectedExtras[i], wingPricer.numberOfExtras(wings[i]), description);
		}

		System.out.println("");
		boolean[] expectedNeedExtra = {false, false, true, false, true, true, true, true, true, true};
		for (int i=0; i<wings.length; i++) {
			description = String.format("wingPricer.needAnExtraBox(%d)", wings[i]);
			if (expectedNeedExtra[i]) Test.forTrue(wingPricer.needAnExtraBox(wings[i]), description);
			else Test.forFalse(wingPricer.needAnExtraBox(wings[i]), description);
		}
		
		System.out.println("");
		int[] expectedBoxes = {0, 0, 1, 1, 2, 3, 3, 5, 8, 20};
		for (int i=0; i<wings.length; i++) {
			description = String.format("wingPricer.numberOfBoxes(%d)", wings[i]);
			Test.forEqualInts(expectedBoxes[i], wingPricer.numberOfBoxes(wings[i]), description);
		}

		System.out.println("");
		double[] expectedPrice = {0.00, 0.00, 5.40, 7.49, 11.09, 18.58, 20.38, 35.36, 54.23, 147.71};
		for (int i=0; i<wings.length; i++) {
			description = String.format("wingPricer.priceFor(%d)", wings[i]);
			Test.forEqualDoubles(expectedPrice[i], wingPricer.priceFor(wings[i]), tolerance, description);
		}

		// Tests for poppers
		
		popperPricer = new Pricer(36, 17.99, 0.75);

		int[] poppers = {-80, 0, 15, 36, 150};
		
		System.out.println("");
		double[] expectedPopperPrice = {0.00, 0.00, 11.25, 17.99, 76.46};
		for (int i=0; i<poppers.length; i++) {
			description = String.format("popperPricer.priceFor(%d)", poppers[i]);
			Test.forEqualDoubles(expectedPopperPrice[i], popperPricer.priceFor(poppers[i]), tolerance, description);
		}
		
		// Re-test for wings (just in case)

		System.out.println("");
		for (int i=0; i<wings.length; i++) {
			description = String.format("After testing popperPricer - wingPricer.priceFor(%d)", wings[i]);
			Test.forEqualDoubles(expectedPrice[i], wingPricer.priceFor(wings[i]), tolerance, description);
		}

	}
	
}
