Commit bd10e078 authored by Fabian Becker's avatar Fabian Becker

More StringTools tests

refs #53
parent 74e5dbd5
......@@ -10,7 +10,7 @@ package eva2.optimization.operator.paramcontrol;
// * Adapt an instance parameter by time, from given start to end value.
// * This only works if iterations are known. The new variant allows exponential adaption,
// * where the second parameter (endV) is interpreted as halfing time in percent of the
// * where the second parameter (endV) is interpreted as halving time in percent of the
// * full run.
// *
// * @author mkron
......@@ -11,7 +11,7 @@ import;
* frequency, turning sin(t) into sin(((t+1)^d)-1) which is linear for d=1. For slightly smaller values,
* the frequency slowly decreases, while for slightly larger values, it slowly increases.
@Description("Sinusoidally oscillating value, the frequency may be varyied with time. E.g. use dampening 0.9 " +
@Description("Sinusoidally oscillating value, the frequency may be varied with time. E.g. use dampening 0.9 " +
"for a slightly decreasing frequency, dampening 1.1 for a slight increase. The frequency is modified " +
"in the form sin(t) -> sin(-1+(t+1)^d)")
public class SinusoidalParamAdaption implements InterfaceHasUpperDoubleBound, ParamAdaption, GenericParamAdaption, Serializable {
......@@ -2,7 +2,9 @@ package;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
......@@ -110,4 +112,67 @@ public class StringToolsTest {
assertEquals("This is a string <sub>12</sub>", StringTools.subscriptIndices("This is a string 12"));
assertEquals("ϕ<sub>10</sub>", StringTools.subscriptIndices("ϕ10"));
public void testDeleteChar() throws Exception {
assertEquals("Taylor", StringTools.deleteChar('s', "Taylors"));
assertEquals("Swift", StringTools.deleteChar('q', "Swift"));
public void testGetSubstringAfterLast() throws Exception {
assertEquals("Swift", StringTools.getSubstringAfterLast("TaylorSwift", 'r'));
assertEquals("Bad Blood", StringTools.getSubstringAfterLast("Bad Blood", 'q'));
public void testConcatFields() throws Exception {
List<String> list = new ArrayList<>();
assertEquals("Taylor,Swift,Bad", StringTools.concatFields(list, ","));
assertEquals("Taylor,Swift,Bad,Blood", StringTools.concatFields(
new String[]{"Taylor", "Swift", "Bad", "Blood"},
public void testExpandPrefixZeros() throws Exception {
assertEquals("01", StringTools.expandPrefixZeros(1, 19));
assertEquals("0001", StringTools.expandPrefixZeros(1, 1900));
assertEquals("000001", StringTools.expandPrefixZeros(1, 219837));
assertEquals("00001", StringTools.expandPrefixZeros(1, 12398));
public void testConcatValues() throws Exception {
List<Object> list = new ArrayList<>();
assertEquals("Foo;12;Sieben", StringTools.concatValues(list, ";"));
public void testSimplifySymbols() throws Exception {
assertEquals("foo-bar", StringTools.simplifySymbols("foo--bar"));
assertEquals("foo_bar", StringTools.simplifySymbols("foo__bar"));
assertEquals("foo_bar", StringTools.simplifySymbols("foo_-bar"));
assertEquals("foo_bar", StringTools.simplifySymbols("foo-_bar"));
assertEquals("foobar", StringTools.simplifySymbols("f(o){o}b*[a]r"));
assertEquals("foo-bar", StringTools.simplifySymbols("foo;bar"));
assertEquals("foo-bar", StringTools.simplifySymbols("foo,bar"));
assertEquals("foo-bar", StringTools.simplifySymbols("foo\\bar"));
assertEquals("foo-bar", StringTools.simplifySymbols("foo/bar"));
assertEquals("foo_bar", StringTools.simplifySymbols("foo bar"));
assertEquals("foo_bar", StringTools.simplifySymbols("foo\n\tbar"));
assertEquals("foo_bar_", StringTools.simplifySymbols("foo\tbar\n"));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment