TriangleUtilitiesTest.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import org.junit.Assert;
  2. import org.junit.Test;
  3. public class TriangleUtilitiesTest {
  4. @Test
  5. public void getRow() {
  6. String expected = "********************";
  7. int width = 20;
  8. String actual = TriangleUtilities.getRow(width);
  9. Assert.assertEquals(expected, actual);
  10. }
  11. @Test
  12. public void getTriangleTest1() {
  13. String expected =
  14. "*\n" +
  15. "**\n" +
  16. "***\n" +
  17. "****\n" +
  18. "*****\n" +
  19. "******\n" +
  20. "*******\n" +
  21. "********\n" +
  22. "*********\n";
  23. String actual = TriangleUtilities.getTriangle(10);
  24. Assert.assertEquals(expected, actual);
  25. }
  26. @Test
  27. public void getTriangleTest2() {
  28. String expected =
  29. "*\n" +
  30. "**\n" +
  31. "***\n" +
  32. "****\n";
  33. String actual = TriangleUtilities.getTriangle(5);
  34. Assert.assertEquals(expected, actual);
  35. }
  36. @Test
  37. public void testGetLargeTriangle() {
  38. String expected =
  39. "*\n" +
  40. "**\n" +
  41. "***\n" +
  42. "****\n" +
  43. "*****\n" +
  44. "******\n" +
  45. "*******\n" +
  46. "********\n" +
  47. "*********\n";
  48. String actual = TriangleUtilities.getLargeTriangle();
  49. Assert.assertEquals(expected, actual);
  50. }
  51. @Test
  52. public void testGetSmallTriangle() {
  53. String expected =
  54. "*\n" +
  55. "**\n" +
  56. "***\n" +
  57. "****\n";
  58. String actual = TriangleUtilities.getSmallTriangle();
  59. Assert.assertEquals(expected, actual);
  60. }
  61. }