lots of exercises in java... from https://github.com/exercism/java

OctalTest.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import org.junit.Test;
  2. import org.junit.Ignore;
  3. import org.junit.runner.RunWith;
  4. import org.junit.runners.Parameterized;
  5. import java.util.Arrays;
  6. import java.util.Collection;
  7. import static org.junit.Assert.assertEquals;
  8. @RunWith(Parameterized.class)
  9. public class OctalTest {
  10. private String input;
  11. private int expectedOutput;
  12. @Parameterized.Parameters
  13. public static Collection<Object[]> data() {
  14. return Arrays.asList(new Object[][]{
  15. {"1", 1},
  16. {"10", 8},
  17. {"17", 15},
  18. {"11", 9},
  19. {"130", 88},
  20. {"2047", 1063},
  21. {"7777", 4095},
  22. {"1234567", 342391},
  23. {"carrot", 0},
  24. {"8", 0},
  25. {"9", 0},
  26. {"6789", 0},
  27. {"abc1z", 0},
  28. {"011", 9}
  29. });
  30. }
  31. public OctalTest(String input, int expectedOutput) {
  32. this.input = input;
  33. this.expectedOutput = expectedOutput;
  34. }
  35. @Test
  36. public void test() {
  37. Octal octal = new Octal(input);
  38. assertEquals(expectedOutput, octal.getDecimal());
  39. }
  40. }