@Override public Tables newSibling() { return new Tables(); }
@Override public Tables newChild() { return new Tables(); }
@Test public void testEmptyTable_ShouldBeVisibleAsEmpty() { Tables emptyTable = new Tables(); String markup = "(empty table)"; assertEquals(markup, emptyTable.toMarkup()); }
@Test public void testEmptyTable_CanBeIndicatedInMarkup() { Tables emptyTable = new Tables(); String markup = "(empty table)"; assertEquals(emptyTable, Tables.parse(markup)); }
public static Rows parse(String markup) { Tables table = new Tables(); String[] rows = markup.split("\\n"); for (String cells : rows) { if (StringUtils.isBlank(cells)) { continue; } Rows row = ( Rows ) table.addChild(); if ( ! isRowEmpty(cells)) { row.addChild(Cells.parse(cells)); } } return ( Rows ) table.firstChild(); }
private FakeExample createFakeExampleForInterpreterRow(Rows theInterpreterRow) { FakeExample table = new Tables(); table.addChild(theInterpreterRow); table.addChild(new Rows()); table.addChild(new Rows()); return table; } }
@Test public void testEmptyRowInATable_ShouldBeVisibleAsEmpty() { Tables emptyRowInATable = new Tables(); emptyRowInATable.row(1, 2, 3).row().row(7, 8, 9); String markup = "[ 1 ][ 2 ][ 3 ]\n(empty row)\n[ 7 ][ 8 ][ 9 ]"; assertEquals(markup, emptyRowInATable.toMarkup()); }
@Test public void testEmptyRowInATable_CanBeIndicatedInTheMarkup() { Tables emptyRowInATable = new Tables(); emptyRowInATable.row(1, 2, 3).row().row(7, 8, 9); String markup = "[ 1 ][ 2 ][ 3 ]\n(empty row)\n[ 7 ][ 8 ][ 9 ]"; assertEquals(emptyRowInATable, Tables.parse(markup)); }
@Test public void testSeveralTables_ShouldBeSeparatedWithARowOfStarsWhenDisplayed() { Tables tables = new Tables(); tables.row(1, 2).row(3, 4); tables.table().row(5, 6).row(7, 8); String markup = "[ 1 ][ 2 ]\n[ 3 ][ 4 ]\n****\n[ 5 ][ 6 ]\n[ 7 ][ 8 ]"; assertEquals(markup, tables.toMarkup()); }
@Test public void testSeveralTables_ShouldBeParsedFromMarkupCorrectly() { Tables tables = new Tables(); tables.row(1, 2).row(3, 4); tables.table().row(5, 6).row(7, 8); String markup = "[ 1 ][ 2 ]\n[ 3 ][ 4 ]\n****\n[ 5 ][ 6 ]\n[ 7 ][ 8 ]"; assertEquals(tables, Tables.parse(markup)); } }
public AnnotationTable annotations() { FakeExample example = new Tables(); example.addChild(new Rows()); example.addChild(( Rows ) table.at(0, 0)); FakeSpecification specification = new FakeSpecification(example); interpreter.interpret(specification); prepareRWIE(specification.stats()); return new AnnotationTable(table); }
@Test public void testBlankLinesInMarkupTable_ShouldBeIgnoredDuringParsing() { Tables blankLinesInMarkupTable = new Tables(); blankLinesInMarkupTable.row(1, 2, 3).row(4, 5, 6).row(7, 8, 9); blankLinesInMarkupTable.table().row(1, 2, 3).row(4, 5, 6).row(7, 8, 9); String markup = "\n\n[ 1 ][ 2 ][ 3 ]\n\n[ 4 ][ 5 ][ 6 ]\n[ 7 ][ 8 ][ 9 ]\n\n****\n\n[ 1 ][ 2 ][ 3 ]\n[ 4 ][ 5 ][ 6 ]\n[ 7 ][ 8 ][ 9 ]\n\n"; assertEquals(blankLinesInMarkupTable, Tables.parse(markup)); }
public void enterRow(String val) { enterRow = val; DoSetupInterpreter setup = new DoSetupInterpreter(new PlainOldFixture(new MyFixture(enterRow))); FakeExample table = new Tables(); table.addChild(new Rows()); table.addChild(row); FakeSpecification fakeSpecification = new FakeSpecification(table); setup.interpret(fakeSpecification); prepareRWIE(fakeSpecification.stats()); }
public void enterRow(String val) { enterRow = val; SetupInterpreter setup = new SetupInterpreter(new PlainOldFixture(new MyFixture(this))); FakeExample table = new Tables(); table.addChild(new Rows()); table.addChild(new Rows(headers(row))); table.addChild(row); FakeSpecification fakeSpecification = new FakeSpecification(table); setup.interpret(fakeSpecification); prepareRWIE(fakeSpecification.stats()); }