Catch exceptions caused by fetching with invalid indices

This commit is contained in:
Masaki Mori
2015-09-09 11:15:56 +09:00
parent e7daae3912
commit b846605894
2 changed files with 24 additions and 0 deletions
@@ -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"),