Skip to content

Commit

Permalink
Return long value when under min int value from IntFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alpri Else committed Aug 30, 2022
1 parent 0d8ebee commit 6cfcea0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Object filter(Object var, JinjavaInterpreter interpreter, String... args)
}

private Object convertResult(Long result) {
if (result > Integer.MAX_VALUE) {
if (result < Integer.MIN_VALUE || result > Integer.MAX_VALUE) {
return result;
}
return result.intValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public void itUsesLongsForLargeValueDefaults() {
.isEqualTo(1000000000001L);
}

@Test
public void itUsesLongsForVerySmallValues() {
assertThat(filter.filter("-42595200000", interpreter)).isEqualTo(-42595200000L);
}

@Test
public void itConvertsProperlyInExpressionTest() {
assertThat(interpreter.render("{{ '3'|int in [null, 4, 5, 6, null, 3] }}"))
Expand Down

0 comments on commit 6cfcea0

Please sign in to comment.