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

PrimeTest.java 865B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import org.junit.Test;
  2. import org.junit.Ignore;
  3. import org.junit.Rule;
  4. import org.junit.rules.ExpectedException;
  5. import static org.hamcrest.CoreMatchers.*;
  6. import static org.junit.Assert.*;
  7. public class PrimeTest {
  8. @Rule
  9. public ExpectedException thrown = ExpectedException.none();
  10. @Test
  11. public void testFirstPrime() {
  12. assertThat(Prime.nth(1), is(2));
  13. }
  14. @Ignore
  15. @Test
  16. public void testSecondPrime() {
  17. assertThat(Prime.nth(2), is(3));
  18. }
  19. @Ignore
  20. @Test
  21. public void testSixthPrime() {
  22. assertThat(Prime.nth(6), is(13));
  23. }
  24. @Ignore
  25. @Test
  26. public void testBigPrime() {
  27. assertThat(Prime.nth(10001), is(104743));
  28. }
  29. @Ignore
  30. @Test
  31. public void testUndefinedPrime() {
  32. thrown.expect(IllegalArgumentException.class);
  33. Prime.nth(0);
  34. }
  35. }