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

MarkdownTest.java 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import org.junit.Before;
  2. import org.junit.Ignore;
  3. import org.junit.Test;
  4. import static org.junit.Assert.assertEquals;
  5. public class MarkdownTest {
  6. private Markdown markdown;
  7. @Before
  8. public void setup() {
  9. markdown = new Markdown();
  10. }
  11. @Test
  12. public void normalTextAsAParagraph() {
  13. String input = "This will be a paragraph";
  14. String expected = "<p>This will be a paragraph</p>";
  15. assertEquals(expected, markdown.parse(input));
  16. }
  17. @Ignore("Remove to run test")
  18. @Test
  19. public void italics() {
  20. String input = "_This will be italic_";
  21. String expected = "<p><em>This will be italic</em></p>";
  22. assertEquals(expected, markdown.parse(input));
  23. }
  24. @Ignore("Remove to run test")
  25. @Test
  26. public void boldText() {
  27. String input = "__This will be bold__";
  28. String expected = "<p><strong>This will be bold</strong></p>";
  29. assertEquals(expected, markdown.parse(input));
  30. }
  31. @Ignore("Remove to run test")
  32. @Test
  33. public void normalItalicsAndBoldText() {
  34. String input = "This will _be_ __mixed__";
  35. String expected = "<p>This will <em>be</em> <strong>mixed</strong></p>";
  36. assertEquals(expected, markdown.parse(input));
  37. }
  38. @Ignore("Remove to run test")
  39. @Test
  40. public void withH1HeaderLevel() {
  41. String input = "# This will be an h1";
  42. String expected = "<h1>This will be an h1</h1>";
  43. assertEquals(expected, markdown.parse(input));
  44. }
  45. @Ignore("Remove to run test")
  46. @Test
  47. public void withH2HeaderLevel() {
  48. String input = "## This will be an h2";
  49. String expected = "<h2>This will be an h2</h2>";
  50. assertEquals(expected, markdown.parse(input));
  51. }
  52. @Ignore("Remove to run test")
  53. @Test
  54. public void withH6HeaderLevel() {
  55. String input = "###### This will be an h6";
  56. String expected = "<h6>This will be an h6</h6>";
  57. assertEquals(expected, markdown.parse(input));
  58. }
  59. @Ignore("Remove to run test")
  60. @Test
  61. public void unorderedLists() {
  62. String input = "* Item 1\n* Item 2";
  63. String expected = "<ul><li>Item 1</li><li>Item 2</li></ul>";
  64. assertEquals(expected, markdown.parse(input));
  65. }
  66. @Ignore("Remove to run test")
  67. @Test
  68. public void aLittleBitOfEverything() {
  69. String input = "# Header!\n* __Bold Item__\n* _Italic Item_";
  70. String expected = "<h1>Header!</h1><ul><li><strong>Bold Item</strong></li><li><em>Italic Item</em></li></ul>";
  71. assertEquals(expected, markdown.parse(input));
  72. }
  73. }