Skip to content

Instantly share code, notes, and snippets.

@eddieberklee
Created March 28, 2014 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddieberklee/9842081 to your computer and use it in GitHub Desktop.
Save eddieberklee/9842081 to your computer and use it in GitHub Desktop.
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