01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.xs.bindings;
17:
18: import javax.xml.namespace.QName;
19:
20: import org.geotools.xml.ElementInstance;
21: import org.geotools.xs.TestSchema;
22:
23: public class XSDoubleStrategyTest extends TestSchema {
24: /**
25: * For example, -1E4, 1267.43233E12, 12.78e-2, 12 , -0, 0 and INF are all legal literals for double.
26: *
27: */
28:
29: /*
30: * Test method for 'org.geotools.xml.strategies.xs.XSDoubleStrategy.parse(Element, Node[], Object)'
31: */
32: public void testParse() throws Exception {
33: validateValues("-1E4", new Double(-1E4));
34: validateValues("1267.43233E12", new Double(1267.43233E12));
35: validateValues("12.78e-2", new Double(12.78e-2));
36: validateValues("12", new Double(12));
37: validateValues("-0", new Double("-0"));
38: validateValues("0", new Double(0));
39:
40: ElementInstance element = element("INF", XS.DOUBLE);
41: assertEquals(new Double(Double.POSITIVE_INFINITY), strategy
42: .parse(element, "INF"));
43: }
44:
45: public void testIntegerParse() throws Exception {
46: ElementInstance element = element("12345", XS.INTEGER);
47: assertEquals(new Double(12345.0), strategy.parse(element,
48: "12345"));
49: }
50:
51: protected QName getQName() {
52: return XS.DOUBLE;
53: }
54: }
|