Package org.freeplane.features.format

Examples of org.freeplane.features.format.FormattedNumber


  }
 
  @Test
  public void testNestedIFormattedObject() {
    double number = 1.123456;
    final FormattedNumber formattedNumber = new FormattedNumber(number, "#.##");
    final FormattedObject formattedObject  = new FormattedObject(formattedNumber, "x: %s");
    assertEquals("wrong pattern", "x: %s", formattedObject.getPattern());
    assertEquals("wrong formatting", "x: 1.12", formattedObject.toString());
  }
View Full Code Here


  }

  @Test
  public void testDefaultPattern() {
    double number = 1.123456;
    final FormattedNumber formattedNumber = new FormattedNumber(number);
    assertEquals("wrong default pattern", "#0.####", formattedNumber.getPattern());
    // expect a rounded number
    assertEquals("wrong default formatting", "1.1235", formattedNumber.toString());
  }
View Full Code Here

  }

  @Test
  public void testWithPattern() {
    double number = 1.123456;
    final FormattedNumber formattedNumber = new FormattedNumber(number, "#.##");
    assertEquals("wrong pattern", "#.##", formattedNumber.getPattern());
    assertEquals("wrong formatting", "1.12", formattedNumber.toString());
  }
View Full Code Here

  }
 
  @Test
  public void testLocaleDependence() {
    double number = 1.123456;
    final FormattedNumber formattedNumber = new FormattedNumber(number, "#.##");
    assertEquals("wrong formatting", "1.12", formattedNumber.toString());
    Locale.setDefault(new Locale("de"));
    // FormattedNumber evaluates the format only once
    assertEquals("no support for on-the-fly-changes of locale", "1.12", formattedNumber.toString());
    // FormattedNumber caches the formats and formats evaluate the locale only once
    assertEquals("no support for on-the-fly-changes of locale", "1.12", new FormattedNumber(number, "#.##").toString());
    // a new pattern - not cached
    assertEquals("formatting should be locale dependent", "1,12", new FormattedNumber(number, "#.00").toString());
  }
View Full Code Here

  }

  @Test
  public void testSerialization() {
    double number = 1.123456;
    final FormattedNumber formattedNumber = new FormattedNumber(number, "#.##");
    final String serialized = "1.123456|#.##";
    assertEquals(serialized, FormattedNumber.serialize(formattedNumber));
    assertEquals(formattedNumber, FormattedNumber.deserialize(serialized));
  }
View Full Code Here

    assertEquals(formattedNumber, FormattedNumber.deserialize(serialized));
  }
 
  @Test
  public void testCompareTo() {
    final FormattedNumber formattedNumberNull = new FormattedNumber(null);
    Double number1 = 1.123456;
    final FormattedNumber formattedNumber1 = new FormattedNumber(number1);
    Double number2 = 1.123457;
    final FormattedNumber formattedNumber2 = new FormattedNumber(number2);
    assertEquals(-1, number1.compareTo(number2));
    assertEquals(-1, formattedNumber1.compareTo(formattedNumber2));
    assertEquals(-1, formattedNumberNull.compareTo(formattedNumber2));
    assertEquals(1, formattedNumber1.compareTo(null));

    assertEquals(1, number2.compareTo(number1));
    assertEquals(1, formattedNumber2.compareTo(formattedNumber1));
    // NPE (OK - only limited support for nulls): assertEquals(1, formattedNumber2.compareTo(formattedNumberNull));
    assertEquals(-1, formattedNumberNull.compareTo(formattedNumber1));
  }
View Full Code Here

TOP

Related Classes of org.freeplane.features.format.FormattedNumber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.