use of uk.me.parabola.mkgmap.osmstyle.actions.Action in project mkgmap by openstreetmap.
the class ActionReaderTest method testFreeForm.
/**
* Test with embedded comment, newlines, semicolon used as separator.
*/
@Test
public void testFreeForm() {
List<Action> actions = readActionsFromString(" { set web='world wide';" + "set \nribbon = 'yellow' \n# a comment } ");
assertEquals("number of actions", 2, actions.size());
Element el = stdElementRun(actions);
assertEquals("park not overwritten", "no", el.getTag("park"));
assertEquals("word with spaces", "world wide", el.getTag("web"));
assertEquals("yellow ribbon", "yellow", el.getTag("ribbon"));
}
use of uk.me.parabola.mkgmap.osmstyle.actions.Action in project mkgmap by openstreetmap.
the class ActionReaderTest method testDoubleName.
/**
* Test with two name actions. This works just the same as having several
* name options on the same name command, in that it is still the
* first one to match that counts.
*/
@Test
public void testDoubleName() {
List<Action> actions = readActionsFromString("{name '${name} (${ref})' |" + " '${ref}' | '${name}' ; " + " name 'fred';}");
// Something that matches nothing in the first name command.
Element el = makeElement();
Rule rule = new ActionRule(null, actions);
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("no tags, second action matches", "fred", el.getName());
el = makeElement();
el.addTag("ref", "A1");
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("just a ref tag", "A1", el.getName());
el = makeElement();
el.addTag("ref", "A1");
el.addTag("name", "Main St");
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("ref and name", "Main St (A1)", el.getName());
}
use of uk.me.parabola.mkgmap.osmstyle.actions.Action in project mkgmap by openstreetmap.
the class ActionReaderTest method testAlternatives.
@Test
public void testAlternatives() {
List<Action> actions = readActionsFromString("{set fred = '${park}' | 'default value'}");
Element el = makeElement();
Rule rule = new ActionRule(null, actions);
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("first alternative", "no", el.getTag("fred"));
}
use of uk.me.parabola.mkgmap.osmstyle.actions.Action in project mkgmap by openstreetmap.
the class ActionReaderTest method testMultipleNoSeparators.
@Test
public void testMultipleNoSeparators() {
List<Action> actions = readActionsFromString("{" + "set park='${notset}' | yes " + "add fred=other " + "set pooh=bear}");
assertEquals("number of actions", 3, actions.size());
Element el = stdElementRun(actions);
assertEquals("park set to yes", "yes", el.getTag("park"));
assertEquals("fred set", "other", el.getTag("fred"));
assertEquals("pooh set", "bear", el.getTag("pooh"));
}
use of uk.me.parabola.mkgmap.osmstyle.actions.Action in project mkgmap by openstreetmap.
the class ActionReaderTest method testMultipleCommands.
/**
* Test several commands in the block. They should all be executed.
*/
@Test
public void testMultipleCommands() {
List<Action> actions = readActionsFromString("{set park=yes; add fred=other;" + "set pooh=bear}");
assertEquals("number of actions", 3, actions.size());
Element el = stdElementRun(actions);
assertEquals("park set to yes", "yes", el.getTag("park"));
assertEquals("fred set", "other", el.getTag("fred"));
assertEquals("pooh set", "bear", el.getTag("pooh"));
}
Aggregations