FizzBuzzMainTest.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 FizzBuzzMainTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class FizzBuzzMainTest
  12. {
  13. FizzBuzzMain fizzBuzzMain = new FizzBuzzMain();
  14. @Test
  15. public void testNonMultiples()
  16. {
  17. assertEquals("2", fizzBuzzMain.main(1));
  18. assertEquals("2", fizzBuzzMain.main(2));
  19. assertEquals("2", fizzBuzzMain.main(4));
  20. assertEquals("2", fizzBuzzMain.main(7));
  21. assertEquals("2", fizzBuzzMain.main(8));
  22. assertEquals("2", fizzBuzzMain.main(11));
  23. }
  24. @Test
  25. public void testMultiplesOf3()
  26. {
  27. assertEquals("Fizz", fizzBuzzMain.main(3));
  28. assertEquals("Fizz", fizzBuzzMain.main(6));
  29. assertEquals("Fizz", fizzBuzzMain.main(9));
  30. assertEquals("Fizz", fizzBuzzMain.main(12));
  31. assertEquals("Fizz", fizzBuzzMain.main(18));
  32. assertEquals("Fizz", fizzBuzzMain.main(21));
  33. }
  34. @Test
  35. public void testMultiplesOf5()
  36. {
  37. assertEquals("Buzz", fizzBuzzMain.main(5));
  38. assertEquals("Buzz", fizzBuzzMain.main(10));
  39. assertEquals("Buzz", fizzBuzzMain.main(20));
  40. assertEquals("Buzz", fizzBuzzMain.main(25));
  41. assertEquals("Buzz", fizzBuzzMain.main(35));
  42. assertEquals("Buzz", fizzBuzzMain.main(40));
  43. }
  44. @Test
  45. public void testMultiplesOf3And5()
  46. {
  47. assertEquals("FizzBuzz", fizzBuzzMain.main(15));
  48. assertEquals("FizzBuzz", fizzBuzzMain.main(30));
  49. assertEquals("FizzBuzz", fizzBuzzMain.main(45));
  50. assertEquals("FizzBuzz", fizzBuzzMain.main(60));
  51. assertEquals("FizzBuzz", fizzBuzzMain.main(75));
  52. assertEquals("FizzBuzz", fizzBuzzMain.main(90));
  53. }
  54. }