From 453d3928e5acdc1a9793a0f02cd043fe81012353 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sat, 6 Dec 2014 12:53:18 -0800 Subject: [PATCH] Factor the tests a bit. --- .../com/samskivert/mustache/MustacheTest.java | 47 +++++++------------ 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/test/java/com/samskivert/mustache/MustacheTest.java b/src/test/java/com/samskivert/mustache/MustacheTest.java index d57024f..6a12ffd 100644 --- a/src/test/java/com/samskivert/mustache/MustacheTest.java +++ b/src/test/java/com/samskivert/mustache/MustacheTest.java @@ -429,40 +429,29 @@ public class MustacheTest } @Test public void testNewlineSkipping () { - String tmpl = "list:\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())); + testNewlineSkipping("\n"); } @Test public void testNewlineSkippingCRLF () { - String tmpl = "list:\r\n" + - "{{#items}}\r\n" + - "{{this}}\r\n" + - "{{/items}}\r\n" + - "{{^items}}\r\n" + - "no items\r\n" + - "{{/items}}\r\n" + + testNewlineSkipping("\r\n"); + } + + protected void testNewlineSkipping (String sep) { + String tmpl = "list:" + sep + + "{{#items}}" + sep + + "{{this}}" + sep + + "{{/items}}" + sep + + "{{^items}}" + sep + + "no items" + sep + + "{{/items}}" + sep + "endlist"; - test("list:\r\n" + - "one\r\n" + - "two\r\n" + - "three\r\n" + + test("list:" + sep + + "one" + sep + + "two" + sep + + "three" + sep + "endlist", tmpl, context("items", Arrays.asList("one", "two", "three"))); - test("list:\r\n" + - "no items\r\n" + + test("list:" + sep + + "no items" + sep + "endlist", tmpl, context("items", Collections.emptyList())); }