use of org.whole.lang.parsers.IDataTypeParser in project whole by wholeplatform.
the class SchemaDataTypeParsersTest method testDouble.
@Test
public void testDouble() throws Exception {
IDataTypeParser dtp = XsiDefaultDataTypeParser.instance;
// test double
String doubleString = "-12.789438023842092304e+28";
double dValue = dtp.parseDouble(null, doubleString);
assertEquals("-1.2789438023842093E29", dtp.unparseDouble(null, dValue));
doubleString = "+1267.789438023842092304928437987423982E12";
dValue = dtp.parseDouble(null, doubleString);
assertEquals("1.267789438023842E15", dtp.unparseDouble(null, dValue));
doubleString = "00000000.000000";
dValue = dtp.parseDouble(null, doubleString);
assertEquals("0.0E0", dtp.unparseDouble(null, dValue));
assertEquals("INF", dtp.unparseDouble(null, Double.POSITIVE_INFINITY));
assertEquals("-INF", dtp.unparseDouble(null, Double.NEGATIVE_INFINITY));
assertEquals("NaN", dtp.unparseDouble(null, Double.NaN));
try {
dtp.parseDouble(null, "123,456");
fail();
} catch (Exception e) {
}
try {
dtp.parseDouble(null, "1000FFFF");
fail();
} catch (Exception e) {
}
}
use of org.whole.lang.parsers.IDataTypeParser in project whole by wholeplatform.
the class SchemaDataTypeParsersTest method testByte.
@Test
public void testByte() throws Exception {
IDataTypeParser dtp = XsiDefaultDataTypeParser.instance;
// test primitives
assertEquals("-128", dtp.unparseByte(null, dtp.parseByte(null, "-128")));
assertEquals("127", dtp.unparseByte(null, dtp.parseByte(null, "127")));
try {
dtp.parseByte(null, "128");
fail();
} catch (Exception e) {
}
try {
dtp.parseByte(null, "-129");
fail();
} catch (Exception e) {
}
}
use of org.whole.lang.parsers.IDataTypeParser in project whole by wholeplatform.
the class SchemaDataTypeParsersTest method testBoolean.
@Test
public void testBoolean() throws Exception {
IDataTypeParser dtp = XsiDefaultDataTypeParser.instance;
// test boolean
String boolString = "true";
boolean bValue = dtp.parseBoolean(null, boolString);
assertEquals("true", dtp.unparseBoolean(null, bValue));
boolString = "1";
bValue = dtp.parseBoolean(null, boolString);
assertEquals("true", dtp.unparseBoolean(null, bValue));
boolString = "false";
bValue = dtp.parseBoolean(null, boolString);
assertEquals("false", dtp.unparseBoolean(null, bValue));
boolString = "0";
bValue = dtp.parseBoolean(null, boolString);
assertEquals("false", dtp.unparseBoolean(null, bValue));
try {
dtp.parseBoolean(null, "False");
fail();
} catch (Exception e) {
}
try {
dtp.parseBoolean(null, "TRUE");
fail();
} catch (Exception e) {
}
}
use of org.whole.lang.parsers.IDataTypeParser in project whole by wholeplatform.
the class SchemaDataTypeParsersTest method testShort.
@Test
public void testShort() throws Exception {
IDataTypeParser dtp = XsiDefaultDataTypeParser.instance;
// test primitives
assertEquals("-32768", dtp.unparseShort(null, dtp.parseShort(null, "-32768")));
assertEquals("32767", dtp.unparseShort(null, dtp.parseShort(null, "32767")));
try {
dtp.parseShort(null, "32768");
fail();
} catch (Exception e) {
}
try {
dtp.parseShort(null, "-32769");
fail();
} catch (Exception e) {
}
}
use of org.whole.lang.parsers.IDataTypeParser in project whole by wholeplatform.
the class SchemaDataTypeParsersTest method testLong.
@Test
public void testLong() throws Exception {
IDataTypeParser dtp = XsiDefaultDataTypeParser.instance;
// test primitives
assertEquals("-9223372036854775808", dtp.unparseLong(null, dtp.parseLong(null, "-9223372036854775808")));
assertEquals("9223372036854775807", dtp.unparseLong(null, dtp.parseLong(null, "9223372036854775807")));
try {
dtp.parseLong(null, "9223372036854775808");
fail();
} catch (Exception e) {
}
try {
dtp.parseLong(null, "-9223372036854775809");
fail();
} catch (Exception e) {
}
}
Aggregations