|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BigDecimalConverterTestCase | Line # 34 | 17 | 0% | 9 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (17) | |||
| Result | |||
|
0.33333334
|
org.apache.commons.beanutils.converters.BigDecimalConverterTestCase.testSimpleConversion
org.apache.commons.beanutils.converters.BigDecimalConverterTestCase.testSimpleConversion
|
1 PASS | |
|
0.14814815
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberPattern
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberPattern
|
1 PASS | |
|
0.14814815
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testBooleanToNumberDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testBooleanToNumberDefault
|
1 PASS | |
|
0.14814815
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberLocale
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberLocale
|
1 PASS | |
|
0.14814815
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testConvertNull
org.apache.commons.beanutils.converters.NumberConverterTestBase.testConvertNull
|
1 PASS | |
|
0.14814815
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberDefault
|
1 PASS | |
|
0.14814815
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidDefault
|
1 PASS | |
|
0.14814815
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidException
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidException
|
1 PASS | |
|
0.14814815
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testConvertNumber
org.apache.commons.beanutils.converters.NumberConverterTestBase.testConvertNumber
|
1 PASS | |
|
0.074074075
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testDateToNumber
org.apache.commons.beanutils.converters.NumberConverterTestBase.testDateToNumber
|
1 PASS | |
|
0.074074075
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testCalendarToNumber
org.apache.commons.beanutils.converters.NumberConverterTestBase.testCalendarToNumber
|
1 PASS | |
|
0.074074075
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringLocale
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringLocale
|
1 PASS | |
|
0.074074075
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringPattern
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringPattern
|
1 PASS | |
|
0.074074075
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidType
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidType
|
1 PASS | |
|
0.074074075
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringArrayToInteger
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringArrayToInteger
|
1 PASS | |
|
0.074074075
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testOtherToStringDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testOtherToStringDefault
|
1 PASS | |
|
0.074074075
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringDefault
|
1 PASS | |
| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 | * contributor license agreements. See the NOTICE file distributed with | |
| 4 | * this work for additional information regarding copyright ownership. | |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 | * (the "License"); you may not use this file except in compliance with | |
| 7 | * the License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | ||
| 18 | package org.apache.commons.beanutils.converters; | |
| 19 | ||
| 20 | import java.math.BigDecimal; | |
| 21 | ||
| 22 | import junit.framework.TestSuite; | |
| 23 | ||
| 24 | import org.apache.commons.beanutils.Converter; | |
| 25 | ||
| 26 | ||
| 27 | /** | |
| 28 | * Test Case for the DoubleConverter class. | |
| 29 | * | |
| 30 | * @author Rodney Waldhoff | |
| 31 | * @version $Revision: 471348 $ $Date: 2006-11-04 21:59:26 -0500 (Sat, 04 Nov 2006) $ | |
| 32 | */ | |
| 33 | ||
| 34 | public class BigDecimalConverterTestCase extends NumberConverterTestBase { | |
| 35 | ||
| 36 | private Converter converter = null; | |
| 37 | ||
| 38 | // ------------------------------------------------------------------------ | |
| 39 | ||
| 40 | 17 |
public BigDecimalConverterTestCase(String name) { |
| 41 | 17 | super(name); |
| 42 | } | |
| 43 | ||
| 44 | // ------------------------------------------------------------------------ | |
| 45 | ||
| 46 | 17 |
public void setUp() throws Exception { |
| 47 | 17 | converter = makeConverter(); |
| 48 | 17 | numbers[0] = new BigDecimal("-12"); |
| 49 | 17 | numbers[1] = new BigDecimal("13"); |
| 50 | 17 | numbers[2] = new BigDecimal("-22"); |
| 51 | 17 | numbers[3] = new BigDecimal("23"); |
| 52 | } | |
| 53 | ||
| 54 | 1 |
public static TestSuite suite() { |
| 55 | 1 | return new TestSuite(BigDecimalConverterTestCase.class); |
| 56 | } | |
| 57 | ||
| 58 | 17 |
public void tearDown() throws Exception { |
| 59 | 17 | converter = null; |
| 60 | } | |
| 61 | ||
| 62 | // ------------------------------------------------------------------------ | |
| 63 | ||
| 64 | 39 |
protected NumberConverter makeConverter() { |
| 65 | 39 | return new BigDecimalConverter(); |
| 66 | } | |
| 67 | ||
| 68 | 2 |
protected NumberConverter makeConverter(Object defaultValue) { |
| 69 | 2 | return new BigDecimalConverter(defaultValue); |
| 70 | } | |
| 71 | ||
| 72 | 48 |
protected Class getExpectedType() { |
| 73 | 48 | return BigDecimal.class; |
| 74 | } | |
| 75 | ||
| 76 | // ------------------------------------------------------------------------ | |
| 77 | ||
| 78 | 1 |
public void testSimpleConversion() throws Exception { |
| 79 | 1 | String[] message= { |
| 80 | "from String", | |
| 81 | "from String", | |
| 82 | "from String", | |
| 83 | "from String", | |
| 84 | "from String", | |
| 85 | "from Byte", | |
| 86 | "from Short", | |
| 87 | "from Integer", | |
| 88 | "from Long", | |
| 89 | "from Float", | |
| 90 | "from Double" | |
| 91 | }; | |
| 92 | ||
| 93 | 1 | Object[] input = { |
| 94 | "-17.2", | |
| 95 | "-1.1", | |
| 96 | "0.0", | |
| 97 | "1.1", | |
| 98 | "17.2", | |
| 99 | new Byte((byte)7), | |
| 100 | new Short((short)8), | |
| 101 | new Integer(9), | |
| 102 | new Long(10), | |
| 103 | new Float("11.1"), | |
| 104 | new Double("12.2") | |
| 105 | }; | |
| 106 | ||
| 107 | 1 | BigDecimal[] expected = { |
| 108 | new BigDecimal("-17.2"), | |
| 109 | new BigDecimal("-1.1"), | |
| 110 | new BigDecimal("0.0"), | |
| 111 | new BigDecimal("1.1"), | |
| 112 | new BigDecimal("17.2"), | |
| 113 | new BigDecimal("7"), | |
| 114 | new BigDecimal("8"), | |
| 115 | new BigDecimal("9"), | |
| 116 | new BigDecimal("10"), | |
| 117 | new BigDecimal("11.1"), | |
| 118 | new BigDecimal("12.2") | |
| 119 | }; | |
| 120 | ||
| 121 | 12 | for(int i=0;i<expected.length;i++) { |
| 122 | 11 | assertEquals( |
| 123 | message[i] + " to BigDecimal", | |
| 124 | expected[i], | |
| 125 | converter.convert(BigDecimal.class,input[i])); | |
| 126 | 11 | assertEquals( |
| 127 | message[i] + " to null type", | |
| 128 | expected[i], | |
| 129 | converter.convert(null,input[i])); | |
| 130 | } | |
| 131 | } | |
| 132 | ||
| 133 | } | |
| 134 | ||
|
||||||||||||