From: kkolinko Date: Sat, 14 May 2011 23:11:37 +0000 (+0000) Subject: Additional tests for coercing of strings in EL arithmetic for https://issues.apache... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=2b3b175d1917d89f9df2791b8449a1646ddcff5b;p=tomcat7.0 Additional tests for coercing of strings in EL arithmetic for https://issues.apache.org/bugzilla/show_bug.cgi?id=47371 All of them pass successfully. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1103250 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/org/apache/el/lang/TestELArithmetic.java b/test/org/apache/el/lang/TestELArithmetic.java index c2dfd7f5d..eb9cd8238 100644 --- a/test/org/apache/el/lang/TestELArithmetic.java +++ b/test/org/apache/el/lang/TestELArithmetic.java @@ -16,6 +16,7 @@ */ package org.apache.el.lang; +import java.math.BigDecimal; import java.math.BigInteger; import junit.framework.TestCase; @@ -50,8 +51,34 @@ public class TestELArithmetic extends TestCase { String.valueOf(ELArithmetic.mod(a, b))); } - public void testBug47371() throws Exception { - assertEquals("1", - String.valueOf(ELArithmetic.add("", Integer.valueOf(1)))); + public void testBug47371bigDecimal() throws Exception { + assertEquals(BigDecimal.valueOf(1), + ELArithmetic.add("", BigDecimal.valueOf(1))); } + + public void testBug47371double() throws Exception { + assertEquals(Double.valueOf(7), ELArithmetic.add("", Double.valueOf(7))); + } + + public void testBug47371doubleString() throws Exception { + assertEquals(Double.valueOf(2), ELArithmetic.add("", "2.")); + } + + public void testBug47371bigInteger() throws Exception { + assertEquals(BigInteger.valueOf(0), + ELArithmetic.multiply("", BigInteger.valueOf(1))); + } + + public void testBug47371long() throws Exception { + assertEquals(Long.valueOf(1), ELArithmetic.add("", Integer.valueOf(1))); + } + + public void testBug47371long2() throws Exception { + assertEquals(Long.valueOf(-3), ELArithmetic.subtract("1", "4")); + } + + public void testBug47371doubleString2() throws Exception { + assertEquals(Double.valueOf(2), ELArithmetic.add("1.", "1")); + } + }