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

SumOfMultiplesTest.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import org.junit.Ignore;
  2. import org.junit.Test;
  3. import static org.junit.Assert.*;
  4. public class SumOfMultiplesTest {
  5. @Test
  6. public void testSumOfMultiplesOf3and4UpToOne() {
  7. int[] set = {
  8. 3,
  9. 5
  10. };
  11. int output = new SumOfMultiples(1, set).getSum();
  12. assertEquals(0, output);
  13. }
  14. @Test
  15. @Ignore("Remove to run test")
  16. public void testSumOfMultiplesOf3and5UpToFour() {
  17. int[] set = {
  18. 3,
  19. 5
  20. };
  21. int output = new SumOfMultiples(4, set).getSum();
  22. assertEquals(3, output);
  23. }
  24. @Test
  25. @Ignore("Remove to run test")
  26. public void testSumOfMultiplesOf3and5UpToTen() {
  27. int[] set = {
  28. 3,
  29. 5
  30. };
  31. int output = new SumOfMultiples(10, set).getSum();
  32. assertEquals(23, output);
  33. }
  34. @Test
  35. @Ignore("Remove to run test")
  36. public void testSumOfMultiplesOf3and5UpToOneHundred() {
  37. int[] set = {
  38. 3,
  39. 5
  40. };
  41. int output = new SumOfMultiples(100, set).getSum();
  42. assertEquals(2318, output);
  43. }
  44. @Test
  45. @Ignore("Remove to run test")
  46. public void testSumOfMultiplesOf3and5UpToOneThousand() {
  47. int[] set = {
  48. 3,
  49. 5
  50. };
  51. int output = new SumOfMultiples(1000, set).getSum();
  52. assertEquals(233168, output);
  53. }
  54. @Test
  55. @Ignore("Remove to run test")
  56. public void testSumOfMultiplesOf7and13and17UpToTwenty() {
  57. int[] set = {
  58. 7,
  59. 13,
  60. 17
  61. };
  62. int output = new SumOfMultiples(20, set).getSum();
  63. assertEquals(51, output);
  64. }
  65. @Test
  66. @Ignore("Remove to run test")
  67. public void testSumOfMultiplesOf4and6UpToFifteen() {
  68. int[] set = {
  69. 4,
  70. 6
  71. };
  72. int output = new SumOfMultiples(15, set).getSum();
  73. assertEquals(30, output);
  74. }
  75. @Test
  76. @Ignore("Remove to run test")
  77. public void testSumOfMultiplesOf5and6and8UpToOneHundredFifty() {
  78. int[] set = {
  79. 5,
  80. 6,
  81. 8
  82. };
  83. int output = new SumOfMultiples(150, set).getSum();
  84. assertEquals(4419, output);
  85. }
  86. @Test
  87. @Ignore("Remove to run test")
  88. public void testSumOfMultiplesOf5and25UpToTwoHundredSeventyFive() {
  89. int[] set = {
  90. 5,
  91. 25
  92. };
  93. int output = new SumOfMultiples(51, set).getSum();
  94. assertEquals(275, output);
  95. }
  96. @Test
  97. @Ignore("Remove to run test")
  98. public void testSumOfMultiplesOf43and47UpToTenThousand() {
  99. int[] set = {
  100. 43,
  101. 47
  102. };
  103. int output = new SumOfMultiples(10000, set).getSum();
  104. assertEquals(2203160, output);
  105. }
  106. @Test
  107. @Ignore("Remove to run test")
  108. public void testSumOfMultiplesOfOneUpToOneHundred() {
  109. int[] set = {
  110. 1
  111. };
  112. int output = new SumOfMultiples(100, set).getSum();
  113. assertEquals(4950, output);
  114. }
  115. @Test
  116. @Ignore("Remove to run test")
  117. public void testSumOfMultiplesOfNoneUpToTenThousand() {
  118. int[] set = {};
  119. int output = new SumOfMultiples(10000, set).getSum();
  120. assertEquals(0, output);
  121. }
  122. }