|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DoubleConverterTestCase | Line # 32 | 18 | 0% | 9 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (17) | |||
| Result | |||
|
0.35714287
|
org.apache.commons.beanutils.converters.DoubleConverterTestCase.testSimpleConversion
org.apache.commons.beanutils.converters.DoubleConverterTestCase.testSimpleConversion
|
1 PASS | |
|
0.14285715
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberLocale
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberLocale
|
1 PASS | |
|
0.14285715
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidDefault
|
1 PASS | |
|
0.14285715
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testConvertNumber
org.apache.commons.beanutils.converters.NumberConverterTestBase.testConvertNumber
|
1 PASS | |
|
0.14285715
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberDefault
|
1 PASS | |
|
0.14285715
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidException
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidException
|
1 PASS | |
|
0.14285715
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberPattern
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringToNumberPattern
|
1 PASS | |
|
0.14285715
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testConvertNull
org.apache.commons.beanutils.converters.NumberConverterTestBase.testConvertNull
|
1 PASS | |
|
0.14285715
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testBooleanToNumberDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testBooleanToNumberDefault
|
1 PASS | |
|
0.071428575
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testDateToNumber
org.apache.commons.beanutils.converters.NumberConverterTestBase.testDateToNumber
|
1 PASS | |
|
0.071428575
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringArrayToInteger
org.apache.commons.beanutils.converters.NumberConverterTestBase.testStringArrayToInteger
|
1 PASS | |
|
0.071428575
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringLocale
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringLocale
|
1 PASS | |
|
0.071428575
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringPattern
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringPattern
|
1 PASS | |
|
0.071428575
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testOtherToStringDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testOtherToStringDefault
|
1 PASS | |
|
0.071428575
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testCalendarToNumber
org.apache.commons.beanutils.converters.NumberConverterTestBase.testCalendarToNumber
|
1 PASS | |
|
0.071428575
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringDefault
org.apache.commons.beanutils.converters.NumberConverterTestBase.testNumberToStringDefault
|
1 PASS | |
|
0.071428575
|
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidType
org.apache.commons.beanutils.converters.NumberConverterTestBase.testInvalidType
|
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 junit.framework.TestSuite; | |
| 21 | ||
| 22 | import org.apache.commons.beanutils.Converter; | |
| 23 | ||
| 24 | ||
| 25 | /** | |
| 26 | * Test Case for the DoubleConverter class. | |
| 27 | * | |
| 28 | * @author Rodney Waldhoff | |
| 29 | * @version $Revision: 471348 $ $Date: 2006-11-04 21:59:26 -0500 (Sat, 04 Nov 2006) $ | |
| 30 | */ | |
| 31 | ||
| 32 | public class DoubleConverterTestCase extends NumberConverterTestBase { | |
| 33 | ||
| 34 | private Converter converter = null; | |
| 35 | ||
| 36 | // ------------------------------------------------------------------------ | |
| 37 | ||
| 38 | 17 |
public DoubleConverterTestCase(String name) { |
| 39 | 17 | super(name); |
| 40 | } | |
| 41 | ||
| 42 | // ------------------------------------------------------------------------ | |
| 43 | ||
| 44 | 17 |
public void setUp() throws Exception { |
| 45 | 17 | converter = makeConverter(); |
| 46 | 17 | numbers[0] = new Double("-12"); |
| 47 | 17 | numbers[1] = new Double("13"); |
| 48 | 17 | numbers[2] = new Double("-22"); |
| 49 | 17 | numbers[3] = new Double("23"); |
| 50 | } | |
| 51 | ||
| 52 | 1 |
public static TestSuite suite() { |
| 53 | 1 | return new TestSuite(DoubleConverterTestCase.class); |
| 54 | } | |
| 55 | ||
| 56 | 17 |
public void tearDown() throws Exception { |
| 57 | 17 | converter = null; |
| 58 | } | |
| 59 | ||
| 60 | // ------------------------------------------------------------------------ | |
| 61 | ||
| 62 | 39 |
protected NumberConverter makeConverter() { |
| 63 | 39 | return new DoubleConverter(); |
| 64 | } | |
| 65 | ||
| 66 | 2 |
protected NumberConverter makeConverter(Object defaultValue) { |
| 67 | 2 | return new DoubleConverter(defaultValue); |
| 68 | } | |
| 69 | ||
| 70 | 48 |
protected Class getExpectedType() { |
| 71 | 48 | return Double.class; |
| 72 | } | |
| 73 | ||
| 74 | // ------------------------------------------------------------------------ | |
| 75 | ||
| 76 | 1 |
public void testSimpleConversion() throws Exception { |
| 77 | 1 | String[] message= { |
| 78 | "from String", | |
| 79 | "from String", | |
| 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 | String.valueOf(Double.MIN_VALUE), | |
| 95 | "-17.2", | |
| 96 | "-1.1", | |
| 97 | "0.0", | |
| 98 | "1.1", | |
| 99 | "17.2", | |
| 100 | String.valueOf(Double.MAX_VALUE), | |
| 101 | new Byte((byte)7), | |
| 102 | new Short((short)8), | |
| 103 | new Integer(9), | |
| 104 | new Long(10), | |
| 105 | new Float(11.1), | |
| 106 | new Double(12.2) | |
| 107 | }; | |
| 108 | ||
| 109 | 1 | Double[] expected = { |
| 110 | new Double(Double.MIN_VALUE), | |
| 111 | new Double(-17.2), | |
| 112 | new Double(-1.1), | |
| 113 | new Double(0.0), | |
| 114 | new Double(1.1), | |
| 115 | new Double(17.2), | |
| 116 | new Double(Double.MAX_VALUE), | |
| 117 | new Double(7), | |
| 118 | new Double(8), | |
| 119 | new Double(9), | |
| 120 | new Double(10), | |
| 121 | new Double(11.1), | |
| 122 | new Double(12.2) | |
| 123 | }; | |
| 124 | ||
| 125 | 14 | for(int i=0;i<expected.length;i++) { |
| 126 | 13 | assertEquals( |
| 127 | message[i] + " to Double", | |
| 128 | expected[i].doubleValue(), | |
| 129 | ((Double)(converter.convert(Double.class,input[i]))).doubleValue(), | |
| 130 | 0.00001D); | |
| 131 | 13 | assertEquals( |
| 132 | message[i] + " to double", | |
| 133 | expected[i].doubleValue(), | |
| 134 | ((Double)(converter.convert(Double.TYPE,input[i]))).doubleValue(), | |
| 135 | 0.00001D); | |
| 136 | 13 | assertEquals( |
| 137 | message[i] + " to null type", | |
| 138 | expected[i].doubleValue(), | |
| 139 | ((Double)(converter.convert(null,input[i]))).doubleValue(), | |
| 140 | 0.00001D); | |
| 141 | } | |
| 142 | } | |
| 143 | ||
| 144 | } | |
| 145 | ||
|
||||||||||||