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

OctalTest.java 1.1KB

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