ToLowerCase
Zur Navigation springen
Zur Suche springen
Beschreibung
Die Funktion toLowerCase wandelt alle Buchstaben von a-z, A-Z einer Zeichenkette in Kleinbuchstaben um. Die Funktion erwartet einen String und gibt einen String zurück.
Syntax
toLowerCase(String zeichenkette)
Parameter
- zeichenkette - die Zeichenkette, in der alle Buchstaben in Großbuchstaben umgewandelt werden sollen
Return Value
- Gibt einen String zurück
Beispiele
Standardfälle
toLowerCase('ICH BIN GROSS') --> returns 'ich bin gross' toLowerCase('ABCDEFGHIJKLMNOPQRSTUVWXYZ') --> returns 'abcdefghijklmnopqrstuvwxyz' toLowerCase('1234567890.!\"§$%&/()=?') --> returns '1234567890.!\"§$%&/()=?'
Benutzung mit Variablen
toLowerCase('[pos=1]') toLowerCase('[var=a]')
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() {
fillInVariableMap.put(7, OMConverter.toObject("<OMOBJ><OMSTR>HELLO</OMSTR></OMOBJ>"));
fillInVariableMap.put(8, OMConverter.toObject("<OMOBJ><OMSTR>HELLO3</OMSTR></OMOBJ>"));
exerciseVariableMap.put("g", OMConverter.toObject("<OMOBJ><OMSTR>HELLO</OMSTR></OMOBJ>"));
exerciseVariableMap.put("h", OMConverter.toObject("<OMOBJ><OMSTR>HELLO3</OMSTR></OMOBJ>"));
}
@Test public void testToLowerCase1() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("abcdefghijklmnopqrstuvwxyz")), Evaluator.evaluate("toLowerCase('ABCDEFGHIJKLMNOPQRSTUVWXYZ')", exerciseVariableMap, fillInVariableMap));
}
@Test public void testToLowerCase2() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("1234567890.!\"§$%&/()=?")), Evaluator.evaluate("toLowerCase('1234567890.!\"§$%&/()=?')", exerciseVariableMap, fillInVariableMap));
}
@Test public void testToLowerCase3() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("abcdefghijklmnopqrstuvwxyz")), Evaluator.evaluate("toLowerCase('abcdefghijklmnopqrstuvwxyz')", exerciseVariableMap, fillInVariableMap));
}
@Test public void testToLowerCase4() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("")), Evaluator.evaluate("toLowerCase('')", exerciseVariableMap, fillInVariableMap));
}
@Test public void testToLowerCase5() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR(" ")), Evaluator.evaluate("toLowerCase(' ')", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testToLowerCaseWithInput1() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello")), Evaluator.evaluate("toLowerCase('[pos=7]')", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testToLowerCaseWithInput2() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello3")), Evaluator.evaluate("toLowerCase('[pos=8]')", exerciseVariableMap, fillInVariableMap));
}
@Test
public void TestToLowerCaseWithVariables1() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello")), Evaluator.evaluate("toLowerCase('[var=g]')", exerciseVariableMap, fillInVariableMap));
}
@Test
public void TestToLowerCaseWithVariables2() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello3")), Evaluator.evaluate("toLowerCase('[var=h]')", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testToLowerCaseWithExpressions1() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("a")), Evaluator.evaluate("toLowerCase(toLowerCase('A'))", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testToLowerCaseWithExpressions2() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("a")), Evaluator.evaluate("toLowerCase(toLowerCase(toLowerCase('A')))", exerciseVariableMap, fillInVariableMap));
}
@Test(expected=ParserException.class)
public void testToLowerCaseWithWrongInputCharacter() {
Evaluator.evaluate("toLowerCase(ab)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidNumberOfArgumentsException.class)
public void testToLowerCaseWithTwoArguments() {
Evaluator.evaluate("toLowerCase('A', 'B')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidNumberOfArgumentsException.class)
public void testToLowerCaseWithThreeArguments() {
Evaluator.evaluate("toLowerCase('A', 'B', 'C')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testToLowerCaseWithMissingExerciseVariable() {
Evaluator.evaluate("toLowerCase('[var=j]')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected=UndefinedFillInVariableException.class)
public void testToLowerCaseWithMissingInput() {
Evaluator.evaluate("toLowerCase('[pos=42]')", exerciseVariableMap, fillInVariableMap);
fail();
}