Factor the tests a bit.

This commit is contained in:
Michael Bayne
2014-12-06 12:53:18 -08:00
parent b33bbda7d9
commit 453d3928e5
@@ -429,40 +429,29 @@ public class MustacheTest
} }
@Test public void testNewlineSkipping () { @Test public void testNewlineSkipping () {
String tmpl = "list:\n" + testNewlineSkipping("\n");
"{{#items}}\n" +
"{{this}}\n" +
"{{/items}}\n" +
"{{^items}}\n" +
"no items\n" +
"{{/items}}\n" +
"endlist";
test("list:\n" +
"one\n" +
"two\n" +
"three\n" +
"endlist", tmpl, context("items", Arrays.asList("one", "two", "three")));
test("list:\n" +
"no items\n" +
"endlist", tmpl, context("items", Collections.emptyList()));
} }
@Test public void testNewlineSkippingCRLF () { @Test public void testNewlineSkippingCRLF () {
String tmpl = "list:\r\n" + testNewlineSkipping("\r\n");
"{{#items}}\r\n" + }
"{{this}}\r\n" +
"{{/items}}\r\n" + protected void testNewlineSkipping (String sep) {
"{{^items}}\r\n" + String tmpl = "list:" + sep +
"no items\r\n" + "{{#items}}" + sep +
"{{/items}}\r\n" + "{{this}}" + sep +
"{{/items}}" + sep +
"{{^items}}" + sep +
"no items" + sep +
"{{/items}}" + sep +
"endlist"; "endlist";
test("list:\r\n" + test("list:" + sep +
"one\r\n" + "one" + sep +
"two\r\n" + "two" + sep +
"three\r\n" + "three" + sep +
"endlist", tmpl, context("items", Arrays.asList("one", "two", "three"))); "endlist", tmpl, context("items", Arrays.asList("one", "two", "three")));
test("list:\r\n" + test("list:" + sep +
"no items\r\n" + "no items" + sep +
"endlist", tmpl, context("items", Collections.emptyList())); "endlist", tmpl, context("items", Collections.emptyList()));
} }