Created
March 28, 2014 20:18
-
-
Save eddieberklee/9842081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import static org.junit.Assert.*; | |
import static org.junit.Assume.*; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.junit.runners.Parameterized; | |
import org.junit.runners.Parameterized.Parameters; | |
import org.junit.experimental.theories.DataPoint; | |
import org.junit.experimental.theories.DataPoints; | |
import org.junit.experimental.theories.Theories; | |
import org.junit.experimental.theories.Theory; | |
@RunWith(Parameterized.class) | |
public class BettingMoneyTest { | |
public int[] amounts; | |
public int[] centsPerDollar; | |
public int finalResult; | |
public int moneyMadeExpected; | |
public BettingMoneyTest (int[] amounts, int[] centsPerDollar, int finalResult, int moneyMadeExpected) { | |
this.amounts = amounts; | |
this.centsPerDollar = centsPerDollar; | |
this.finalResult = finalResult; | |
this.moneyMadeExpected = moneyMadeExpected; | |
} | |
@Parameters | |
public static Collection<Object[]> parameters() { | |
return Arrays.asList(new Object[][] { | |
{new int[] {10,20,30}, new int[] {20,30,40}, 1, 3400}, | |
{new int[] {123,342,424,524,234,634,1000}, new int[] {12,32,42,62,12,53,5000}, 6, -4771900}, | |
{new int[] {5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000}, | |
new int[] {0, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000}, | |
0, 24500000}, | |
{new int[] {1}, new int[] {1}, 0, -1}, | |
}); | |
} | |
@Test | |
public void moneyMadeTest() { | |
int moneyMade = BettingMoney.moneyMade(amounts, centsPerDollar, finalResult); | |
assertEquals(moneyMadeExpected, moneyMade); | |
} | |
// @Test(expected = IllegalArgumentException.class) | |
// public void testExceptionIsThrown() { | |
// int[] amounts = {1,2,3}; | |
// int[] centsPerDollar = {4,5,6,7}; | |
// int finalResult = 1; | |
// BettingMoney.moneyMade(amounts, centsPerDollar, finalResult); | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment