Add toUpperCase and toLowerCase functions #285
This commit is contained in:
@@ -57,6 +57,8 @@ public class StringFunc implements IFunc {
|
||||
FuncExecutor.register(NAME_SPACE_PREFIX + "string.indexOf", this);
|
||||
FuncExecutor.register(NAME_SPACE_PREFIX + "string.startsWith", this);
|
||||
FuncExecutor.register(NAME_SPACE_PREFIX + "string.endsWith", this);
|
||||
FuncExecutor.register(NAME_SPACE_PREFIX + "string.toUpperCase", this);
|
||||
FuncExecutor.register(NAME_SPACE_PREFIX + "string.toLowerCase", this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,4 +147,12 @@ public class StringFunc implements IFunc {
|
||||
return str.endsWith(suffix);
|
||||
}
|
||||
|
||||
public String toUpperCase(String str) {
|
||||
return str.toUpperCase();
|
||||
}
|
||||
|
||||
public String toLowerCase(String str) {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -105,6 +105,20 @@ class StringFuncTests {
|
||||
assertEquals("2021-07-09 22:44:55".endsWith("44:55"), result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToUpperCase() {
|
||||
String funcExpression = "fn.string.toUpperCase(\"aBc\")";
|
||||
String result = (String)FuncExecutor.getInstance().exec(null, funcExpression);
|
||||
assertEquals("aBc".toUpperCase(), result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToLowerCase() {
|
||||
String funcExpression = "fn.string.toLowerCase(\"aBc\")";
|
||||
String result = (String)FuncExecutor.getInstance().exec(null, funcExpression);
|
||||
assertEquals("aBc".toLowerCase(), result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user