Write bunch of java to solve a series of requirements and pass a series of tests to prove your code works the way it should.

WriteLoopsTest.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class WriteLoopsTest.
  7. *
  8. * @author kyounger
  9. * @version 1.2
  10. */
  11. public class WriteLoopsTest
  12. {
  13. /**
  14. * Default constructor for test class WriteLoopsTest
  15. */
  16. public WriteLoopsTest()
  17. {
  18. }
  19. /**
  20. * Sets up the test fixture.
  21. *
  22. * Called before every test case method.
  23. */
  24. @Before
  25. public void setUp()
  26. {
  27. }
  28. /**
  29. * Tears down the test fixture.
  30. *
  31. * Called after every test case method.
  32. */
  33. @After
  34. public void tearDown()
  35. {
  36. }
  37. @Test
  38. public void TestOneToFive()
  39. {
  40. WriteLoops writeLoo1 = new WriteLoops();
  41. assertEquals(5, writeLoo1.oneToFive());
  42. }
  43. @Test
  44. public void TestOneToTen()
  45. {
  46. WriteLoops writeLoo1 = new WriteLoops();
  47. assertEquals(10, writeLoo1.oneToTen());
  48. }
  49. @Test
  50. public void TestStartAtTwentyOne()
  51. {
  52. WriteLoops writeLoo1 = new WriteLoops();
  53. assertEquals(11, writeLoo1.startAtTwentyOne());
  54. }
  55. @Test
  56. public void TestCountDown()
  57. {
  58. WriteLoops writeLoo1 = new WriteLoops();
  59. assertEquals(100, writeLoo1.countDown());
  60. }
  61. //NOTE: Test expected = 0. Rewrote test as Test2to32v2
  62. @Test
  63. public void Test2to32()
  64. {
  65. WriteLoops writeLoo1 = new WriteLoops();
  66. assertEquals(0, writeLoo1.byTwoTo32());
  67. }
  68. @Test
  69. public void Test2to32v2()
  70. {
  71. WriteLoops writeLoo1 = new WriteLoops();
  72. assertEquals(17, writeLoo1.byTwoTo32());
  73. }
  74. @Test
  75. public void TestCountDownFrom5000()
  76. {
  77. WriteLoops writeLoo1 = new WriteLoops();
  78. assertEquals(455, writeLoo1.countDownFrom5000());
  79. }
  80. @Test
  81. public void TestNestedFors()
  82. {
  83. WriteLoops writeLoo1 = new WriteLoops();
  84. assertEquals(100, writeLoo1.nestedFors());
  85. }
  86. @Test
  87. public void TestHelloZipCode()
  88. {
  89. WriteLoops writeLoo1 = new WriteLoops();
  90. assertEquals(47, writeLoo1.helloZipCode());
  91. }
  92. @Test
  93. public void TestDriveHome()
  94. {
  95. WriteLoops writeLoo1 = new WriteLoops();
  96. assertEquals(6, writeLoo1.driveHome());
  97. }
  98. @Test
  99. public void TestCheckGameScore()
  100. {
  101. WriteLoops writeLoo1 = new WriteLoops();
  102. assertEquals(3, writeLoo1.checkGameScore());
  103. }
  104. @Test
  105. public void TestCheckGameScoreDoWhile()
  106. {
  107. WriteLoops writeLoo1 = new WriteLoops();
  108. assertEquals(true, writeLoo1.checkGameScoreDoWhile());
  109. }
  110. @Test
  111. public void TestCheckServer()
  112. {
  113. WriteLoops writeLoo1 = new WriteLoops();
  114. assertEquals(3, writeLoo1.checkServerStatus());
  115. }
  116. }