use of org.freeplane.features.format.FormattedObject in project freeplane by freeplane.
the class FormattedObjectTest method testLocaleDependence.
@Test
public void testLocaleDependence() {
final FormattedObject formattedObject = new FormattedObject(1.1234, "%.3f");
assertEquals("wrong formatting", "1.123", formattedObject.toString());
Locale.setDefault(new Locale("de"));
// the format is evaluated only once
assertEquals("no support for on-the-fly-changes of locale", "1.123", formattedObject.toString());
// FormattedObject does not caches the formats
assertEquals("formatting should be locale dependent", "1,123", new FormattedObject(1.1234, "%.3f").toString());
}
use of org.freeplane.features.format.FormattedObject in project freeplane by freeplane.
the class FormattedObjectTest method testSerializeNumber.
@Test
public void testSerializeNumber() {
double number = 1.123456;
final FormattedObject formattedObject = new FormattedObject(number, "#.##");
final String serialized = "java.lang.Double|1.123456|number:decimal:#.##";
assertEquals(serialized, FormattedObject.serialize(formattedObject));
assertEquals("failure in deserialization", formattedObject, FormattedObject.deserialize(serialized));
}
use of org.freeplane.features.format.FormattedObject in project freeplane by freeplane.
the class FormattedObjectTest method testNestedIFormattedObject.
@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());
}
use of org.freeplane.features.format.FormattedObject in project freeplane by freeplane.
the class FormattedObjectTest method testSerializeString.
@Test
public void testSerializeString() {
String unformattedString = "\"sdf\"|sdf|sdf|: %s";
final FormattedObject formattedObject = new FormattedObject(unformattedString, "|\"x\"|: %s");
final String serialized = ""sdf"|sdf|sdf|: %s|string:formatter:|"x"|: %s";
assertEquals(serialized, FormattedObject.serialize(formattedObject));
assertEquals("failure in deserialization", formattedObject, FormattedObject.deserialize(serialized));
}
use of org.freeplane.features.format.FormattedObject in project freeplane by freeplane.
the class FormattedObjectTest method testStrangeInput.
@Test
public void testStrangeInput() {
final FormattedDate date = new FormattedDate(new Date(), "yyyy-mm-dd");
final FormattedObject formattedObject = new FormattedObject(date, "#.##");
assertEquals("decimal format is not applicable to date", date.toString(), formattedObject.toString());
}
Aggregations