示例#1
0
 public void testAddToMethodAddsGivenValueGivenNumberOfTimesToOriginalValue() throws Exception {
   assertEquals("10", DataType.INTEGER.addTo("10", new Integer(5), 0));
   assertEquals("15", DataType.INTEGER.addTo("10", new Integer(5), 1));
   assertEquals("20", DataType.INTEGER.addTo("10", new Integer(5), 2));
   assertEquals("10.2", DataType.DOUBLE.addTo("10.2", new Double(5.1), 0));
   assertEquals("15.3", DataType.DOUBLE.addTo("10.2", new Double(5.1), 1));
   assertEquals("20.4", DataType.DOUBLE.addTo("10.2", new Double(5.1), 2));
   assertEquals("Hello", DataType.STRING.addTo("Hello", " World", 0));
   assertEquals("Hello World", DataType.STRING.addTo("Hello", " World", 1));
   assertEquals("Hello World World", DataType.STRING.addTo("Hello", " World", 2));
   assertEquals("12/02/2006", DataType.DATE.addTo("12/02/2006", new Integer(5), 0));
   assertEquals("12/07/2006", DataType.DATE.addTo("12/02/2006", new Integer(5), 1));
   assertEquals("01/01/2007", DataType.DATE.addTo("12/31/2006", new Integer(1), 1));
   assertEquals("01/21/2007", DataType.DATE.addTo("12/02/2006", new Integer(5), 10));
 }
示例#2
0
  public void testParseMethodParsesInputStringAndConvertsItToAppropriateObject() throws Exception {
    Object parsedObject = DataType.INTEGER.parse("10");
    assertEquals(10, ((Integer) parsedObject).intValue());

    parsedObject = DataType.DOUBLE.parse("10.3");
    assertEquals(10.3, ((Double) parsedObject).doubleValue(), 0.01);

    parsedObject = DataType.STRING.parse("Some String");
    assertEquals("Some String", ((String) parsedObject));

    parsedObject = DataType.DATE.parse("10");
    assertEquals(10, ((Integer) parsedObject).intValue());
  }