use of org.freeplane.features.format.FormattedNumber in project freeplane by freeplane.
the class FormattedNumberTest method testLocaleDependence.
@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());
}
use of org.freeplane.features.format.FormattedNumber in project freeplane by freeplane.
the class FormattedNumberTest method testCompareTo.
@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));
}
Aggregations