Catch exceptions caused by fetching with invalid indices
This commit is contained in:
@@ -122,6 +122,11 @@ public class MustacheTest
|
||||
"foo", Arrays.asList(context("bar", "baz"), context("bar", "bif"))));
|
||||
}
|
||||
|
||||
@Test public void testListIndexOutOfBoundsSection () {
|
||||
test("", "{{#foo.2}}{{bar}}{{/foo.2}}", context(
|
||||
"foo", Arrays.asList(context("bar", "baz"), context("bar", "bif"))));
|
||||
}
|
||||
|
||||
@Test public void testListItemSection() {
|
||||
test("baz", "{{foo.0.bar}}", context(
|
||||
"foo", Arrays.asList(context("bar", "baz"), context("bar", "bif"))));
|
||||
@@ -139,6 +144,12 @@ public class MustacheTest
|
||||
context("bar", "baz"), context("bar", "bif") }));
|
||||
}
|
||||
|
||||
@Test public void testArrayIndexOutOfBoundsSection () {
|
||||
test("", "{{#foo.2}}{{bar}}{{/foo.2}}",
|
||||
context("foo", new Object[] {
|
||||
context("bar", "baz"), context("bar", "bif") }));
|
||||
}
|
||||
|
||||
@Test public void testArrayItemSection () {
|
||||
test("baz", "{{foo.0.bar}}",
|
||||
context("foo", new Object[] {
|
||||
@@ -157,6 +168,12 @@ public class MustacheTest
|
||||
context("bar", "bif")).iterator()));
|
||||
}
|
||||
|
||||
@Test public void testIteratorIndexOutOfBoundsSection () {
|
||||
test("", "{{#foo.2}}{{bar}}{{/foo.2}}",
|
||||
context("foo", Arrays.asList(context("bar", "baz"),
|
||||
context("bar", "bif")).iterator()));
|
||||
}
|
||||
|
||||
@Test public void testIteratorItemSection () {
|
||||
test("baz", "{{foo.0.bar}}",
|
||||
context("foo", Arrays.asList(context("bar", "baz"),
|
||||
|
||||
Reference in New Issue
Block a user