commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/locale LocaleConvertUtilsTestCase.java
Date Wed, 07 May 2003 19:30:55 GMT
rdonkin     2003/05/07 12:30:52

  Modified:    beanutils/src/test/org/apache/commons/beanutils/locale
                        LocaleConvertUtilsTestCase.java
  Log:
  Applied patch that prevents unit test errooneously failing on computers with comma as the
decimal deliminater. Submitted by Rune Toalango Johannesen.
  
  Revision  Changes    Path
  1.2       +22 -10    jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/locale/LocaleConvertUtilsTestCase.java
  
  Index: LocaleConvertUtilsTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/locale/LocaleConvertUtilsTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocaleConvertUtilsTestCase.java	9 Mar 2003 21:25:17 -0000	1.1
  +++ LocaleConvertUtilsTestCase.java	7 May 2003 19:30:51 -0000	1.2
  @@ -67,6 +67,9 @@
   import java.sql.Time;
   import java.sql.Timestamp;
   import java.util.HashMap;
  +import java.util.Locale;
  +import java.text.DecimalFormat;
  +import java.text.NumberFormat;
   
   import junit.framework.TestCase;
   import junit.framework.Test;
  @@ -82,6 +85,7 @@
    * </p>
    *
    * @author  Michael Szlapa
  + * @author Paul Hamamnt & Rune Johannesen (pairing) - patches.
    * @version $Revision$ $Date$
    */
   
  @@ -89,6 +93,7 @@
   
       // ---------------------------------------------------- Instance Variables
   
  +    private char m_decimalSeparator;
   
       // ---------------------------------------------------------- Constructors
   
  @@ -113,6 +118,13 @@
   
           LocaleConvertUtils.deregister();
   
  +        NumberFormat nf = DecimalFormat.getNumberInstance();
  +        String result = nf.format(1.1);
  +
  +        // could be commas instead of stops in Europe.
  +        m_decimalSeparator = result.charAt(1);
  +
  +
       }
   
   
  @@ -334,9 +346,9 @@
                   LocaleConvertUtils.convert(new Byte((byte) 123)));
           assertEquals("Character->String", "a",
                   LocaleConvertUtils.convert(new Character('a')));
  -        assertEquals("Double->String", "123.4",
  +        assertEquals("Double->String", "123" + m_decimalSeparator + "4",
                   LocaleConvertUtils.convert(new Double((double) 123.4)));
  -        assertEquals("Float->String", "123.4",
  +        assertEquals("Float->String", "123" + m_decimalSeparator + "4",
                   LocaleConvertUtils.convert(new Float((float) 123.4)));
           assertEquals("Integer->String", "123",
                   LocaleConvertUtils.convert(new Integer((int) 123)));
  @@ -510,22 +522,22 @@
           assertEquals(String.class, (Class) value);
           */
   
  -        value = LocaleConvertUtils.convert("123.456", Double.TYPE);
  +        value = LocaleConvertUtils.convert("123" + m_decimalSeparator + "456", Double.TYPE);
           assertTrue(value instanceof Double);
           assertEquals(((Double) value).doubleValue(), (double) 123.456,
                   (double) 0.005);
   
  -        value = LocaleConvertUtils.convert("123.456", Double.class);
  +        value = LocaleConvertUtils.convert("123" + m_decimalSeparator + "456", Double.class);
           assertTrue(value instanceof Double);
           assertEquals(((Double) value).doubleValue(), (double) 123.456,
                   (double) 0.005);
   
  -        value = LocaleConvertUtils.convert("123.456", Float.TYPE);
  +        value = LocaleConvertUtils.convert("123" + m_decimalSeparator + "456", Float.TYPE);
           assertTrue(value instanceof Float);
           assertEquals(((Float) value).floatValue(), (float) 123.456,
                   (float) 0.005);
   
  -        value = LocaleConvertUtils.convert("123.456", Float.class);
  +        value = LocaleConvertUtils.convert("123" + m_decimalSeparator + "456", Float.class);
           assertTrue(value instanceof Float);
           assertEquals(((Float) value).floatValue(), (float) 123.456,
                   (float) 0.005);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message