Skip to content

Commit

Permalink
Merge pull request #2971 from jlerbsc/master
Browse files Browse the repository at this point in the history
Adding test case on PrettyPrinter identation
  • Loading branch information
jlerbsc committed Dec 3, 2020
2 parents fbb4a84 + d057a63 commit 8eff402
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.github.javaparser.ast.expr.VariableDeclarationExpr;
import com.github.javaparser.ast.stmt.Statement;
import com.github.javaparser.ast.type.PrimitiveType;
import com.github.javaparser.printer.PrettyPrinterConfiguration.IndentType;
import com.github.javaparser.printer.PrettyPrinterConfiguration.Indentation;

class PrettyPrinterTest {
Expand Down Expand Up @@ -517,4 +518,34 @@ public void testIssue2535() {
assertTrue(cu.toString().contains(" /* TODO */"));

}

@Test
public void testIndentationWithDefaultSize() {
Indentation indentation = new Indentation(IndentType.SPACES);
assertTrue(indentation.size==4);
assertEquals(" ", indentation.getIndent());
// on-the-fly modification
indentation.size(2);
assertTrue(indentation.size==2);
assertEquals(" ", indentation.getIndent());
}

@Test
public void testIndentationWithCustomSize() {
Indentation indentation = new Indentation(IndentType.TABS,2);
assertTrue(indentation.size==2);
assertEquals("\t\t", indentation.getIndent());
}

@Test
public void testIndentationWithOnTheFlyModifcation() {
Indentation indentation = new Indentation(IndentType.SPACES);
// on-the-fly modification
indentation.size(2);
assertTrue(indentation.size==2);
assertEquals(" ", indentation.getIndent());
indentation.type(IndentType.TABS);
assertTrue(indentation.type == IndentType.TABS);
assertEquals("\t\t", indentation.getIndent());
}
}

0 comments on commit 8eff402

Please sign in to comment.