ToLowerCase: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Zeile 24: | Zeile 24: | ||
<span class="mw-customtoggle-myDivision">[Anzeigen]</span> | <span class="mw-customtoggle-myDivision">[Anzeigen]</span> | ||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | <syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | ||
@BeforeClass | @BeforeClass | ||
public static void beforeTest() { | 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 | @Test public void testToLowerCase1() { | ||
public void | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("abcdefghijklmnopqrstuvwxyz")), Evaluator.evaluate("toLowerCase('ABCDEFGHIJKLMNOPQRSTUVWXYZ')", exerciseVariableMap, fillInVariableMap)); | ||
assertEquals( | |||
} | } | ||
@Test | @Test public void testToLowerCase2() { | ||
public void | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("1234567890.!\"§$%&/()=?")), Evaluator.evaluate("toLowerCase('1234567890.!\"§$%&/()=?')", exerciseVariableMap, fillInVariableMap)); | ||
assertEquals( | |||
} | } | ||
@Test | @Test public void testToLowerCase3() { | ||
public void | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("abcdefghijklmnopqrstuvwxyz")), Evaluator.evaluate("toLowerCase('abcdefghijklmnopqrstuvwxyz')", exerciseVariableMap, fillInVariableMap)); | ||
assertEquals( | |||
} | } | ||
@Test | @Test public void testToLowerCase4() { | ||
public void | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("")), Evaluator.evaluate("toLowerCase('')", exerciseVariableMap, fillInVariableMap)); | ||
assertEquals( | |||
} | } | ||
@Test | @Test public void testToLowerCase5() { | ||
public void | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR(" ")), Evaluator.evaluate("toLowerCase(' ')", exerciseVariableMap, fillInVariableMap)); | ||
assertEquals( | |||
} | } | ||
@Test | @Test | ||
public void | public void testToLowerCaseWithInput1() { | ||
assertEquals( | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello")), Evaluator.evaluate("toLowerCase('[pos=7]')", exerciseVariableMap, fillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testToLowerCaseWithInput2() { | ||
assertEquals( | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello3")), Evaluator.evaluate("toLowerCase('[pos=8]')", exerciseVariableMap, fillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void TestToLowerCaseWithVariables1() { | ||
assertEquals(( | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello")), Evaluator.evaluate("toLowerCase('[var=g]')", exerciseVariableMap, fillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void TestToLowerCaseWithVariables2() { | ||
assertEquals(( | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello3")), Evaluator.evaluate("toLowerCase('[var=h]')", exerciseVariableMap, fillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testToLowerCaseWithExpressions1() { | ||
assertEquals( | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("a")), Evaluator.evaluate("toLowerCase(toLowerCase('A'))", exerciseVariableMap, fillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testToLowerCaseWithExpressions2() { | ||
assertEquals( | assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("a")), Evaluator.evaluate("toLowerCase(toLowerCase(toLowerCase('A')))", exerciseVariableMap, fillInVariableMap)); | ||
} | } | ||
@Test(expected = | @Test(expected=ParserException.class) | ||
public void | public void testToLowerCaseWithWrongInputCharacter() { | ||
Evaluator. | Evaluator.evaluate("toLowerCase(ab)", exerciseVariableMap, fillInVariableMap); | ||
fail(); | |||
} | } | ||
@Test(expected = FunctionInvalidNumberOfArgumentsException.class) | @Test(expected=FunctionInvalidNumberOfArgumentsException.class) | ||
public void | public void testToLowerCaseWithTwoArguments() { | ||
Evaluator. | Evaluator.evaluate("toLowerCase('A', 'B')", exerciseVariableMap, fillInVariableMap); | ||
fail(); | |||
} | } | ||
@Test(expected = FunctionInvalidNumberOfArgumentsException.class) | @Test(expected=FunctionInvalidNumberOfArgumentsException.class) | ||
public void | public void testToLowerCaseWithThreeArguments() { | ||
Evaluator. | Evaluator.evaluate("toLowerCase('A', 'B', 'C')", exerciseVariableMap, fillInVariableMap); | ||
fail(); | |||
} | } | ||
@Test(expected = UndefinedExerciseVariableException.class) | @Test(expected=UndefinedExerciseVariableException.class) | ||
public void | public void testToLowerCaseWithMissingExerciseVariable() { | ||
Evaluator. | Evaluator.evaluate("toLowerCase('[var=j]')", exerciseVariableMap, fillInVariableMap); | ||
fail(); | |||
} | } | ||
@Test(expected = UndefinedFillInVariableException.class) | @Test(expected=UndefinedFillInVariableException.class) | ||
public void | public void testToLowerCaseWithMissingInput() { | ||
Evaluator. | Evaluator.evaluate("toLowerCase('[pos=42]')", exerciseVariableMap, fillInVariableMap); | ||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 19. September 2017, 07:46 Uhr
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();
}