ToLowerCase: Unterschied zwischen den Versionen

Aus JACK Wiki
Wechseln zu: Navigation, Suche
(JUnit Tests)
(JUnit Tests)
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">
private static double PI = Math.PI;
 
 
 
@BeforeClass
 
@BeforeClass
 
public static void beforeTest() {
 
public static void beforeTest() {
OMOBJ to180 = new OMOBJ();
+
OMOBJ zero = new OMOBJ();
+
fillInVariableMap.put(7, OMConverter.toObject("<OMOBJ><OMSTR>HELLO</OMSTR></OMOBJ>"));
to180.setOMI(OMCreator.createOMI(180));
+
fillInVariableMap.put(8, OMConverter.toObject("<OMOBJ><OMSTR>HELLO3</OMSTR></OMOBJ>"));
zero.setOMI(OMCreator.createOMI(0));
 
  
fillIn.put(1, to180);
+
exerciseVariableMap.put("g", OMConverter.toObject("<OMOBJ><OMSTR>HELLO</OMSTR></OMOBJ>"));
fillIn.put(2, zero);
+
exerciseVariableMap.put("h", OMConverter.toObject("<OMOBJ><OMSTR>HELLO3</OMSTR></OMOBJ>"));
 
+
exerVar.put("a", to180);
 
exerVar.put("b", zero);
 
 
}
 
}
  
@Test
+
@Test public void testToLowerCase1() {
public void testToRadians1() {
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("abcdefghijklmnopqrstuvwxyz")), Evaluator.evaluate("toLowerCase('ABCDEFGHIJKLMNOPQRSTUVWXYZ')", exerciseVariableMap, fillInVariableMap));
assertEquals(PI, Evaluator.getNumberResult("toRadians(180)", exerVar, fillIn), 0);
 
 
}
 
}
  
@Test
+
@Test public void testToLowerCase2() {
public void testToRadians2() {
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("1234567890.!\"§$%&/()=?")), Evaluator.evaluate("toLowerCase('1234567890.!\"§$%&/()=?')", exerciseVariableMap, fillInVariableMap));
assertEquals(2 * PI, Evaluator.getNumberResult("toRadians(360)", exerVar, fillIn), 0);
 
 
}
 
}
  
@Test
+
@Test public void testToLowerCase3() {
public void testToRadians3() {
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("abcdefghijklmnopqrstuvwxyz")), Evaluator.evaluate("toLowerCase('abcdefghijklmnopqrstuvwxyz')", exerciseVariableMap, fillInVariableMap));
assertEquals(3 * PI, Evaluator.getNumberResult("toRadians(540)", exerVar, fillIn), 0);
 
 
}
 
}
  
@Test
+
@Test public void testToLowerCase4() {
public void testToRadians4() {
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("")), Evaluator.evaluate("toLowerCase('')", exerciseVariableMap, fillInVariableMap));
assertEquals(PI / 2, Evaluator.getNumberResult("toRadians(90)", exerVar, fillIn), 0);
 
 
}
 
}
  
@Test
+
@Test public void testToLowerCase5() {
public void testToRadians5() {
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR(" ")), Evaluator.evaluate("toLowerCase(' ')", exerciseVariableMap, fillInVariableMap));
assertEquals(-PI, Evaluator.getNumberResult("toRadians(-180)", exerVar, fillIn), 0);
 
 
}
 
}
  
 
@Test
 
@Test
public void testToRadians6() {
+
public void testToLowerCaseWithInput1() {
assertEquals(0, Evaluator.getNumberResult("toRadians(0)", exerVar, fillIn), 0);
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello")), Evaluator.evaluate("toLowerCase('[pos=7]')", exerciseVariableMap, fillInVariableMap));
}
 
 
 
@Test
 
public void testToRadiansWithInput1() {
 
assertEquals(PI, Evaluator.getNumberResult("toRadians('[pos=1]')", exerVar, fillIn), 0);
 
}
 
 
 
@Test
 
public void testToRadiansWithInput2() {
 
assertEquals(0, Evaluator.getNumberResult("toRadians('[pos=2]')", exerVar, fillIn), 0);
 
}
 
 
 
@Test
 
public void testToRadiansWithVariables1() {
 
assertEquals(PI, Evaluator.getNumberResult("toRadians('[var=a]')", exerVar, fillIn), 0);
 
 
 
 
}
 
}
  
 
@Test
 
@Test
public void testToRadiansWithVariables2() {
+
public void testToLowerCaseWithInput2() {
assertEquals(0, Evaluator.getNumberResult("toRadians('[var=b]')", exerVar, fillIn), 0);
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello3")), Evaluator.evaluate("toLowerCase('[pos=8]')", exerciseVariableMap, fillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testToRadiansWithPointNumbers1() {
+
public void TestToLowerCaseWithVariables1() {
assertEquals((PI * .2) / 180, Evaluator.getNumberResult("toRadians(0.2)", exerVar, fillIn), 0);
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello")), Evaluator.evaluate("toLowerCase('[var=g]')", exerciseVariableMap, fillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testToRadiansWithPointNumbers2() {
+
public void TestToLowerCaseWithVariables2() {
assertEquals((-PI * .1) / 180, Evaluator.getNumberResult("toRadians(-0.1)", exerVar, fillIn), 0);
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("hello3")), Evaluator.evaluate("toLowerCase('[var=h]')", exerciseVariableMap, fillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testToRadiansWithExpressions1() {
+
public void testToLowerCaseWithExpressions1() {
assertEquals(0, Evaluator.getNumberResult("toRadians(toRadians(0))", exerVar, fillIn), 0);
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("a")), Evaluator.evaluate("toLowerCase(toLowerCase('A'))", exerciseVariableMap, fillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testToRadiansWithExpressions2() {
+
public void testToLowerCaseWithExpressions2() {
assertEquals(0, Evaluator.getNumberResult("toRadians(toRadians(toRadians(0)))", exerVar, fillIn), 0);
+
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("a")), Evaluator.evaluate("toLowerCase(toLowerCase(toLowerCase('A')))", exerciseVariableMap, fillInVariableMap));
 
}
 
}
  
@Test(expected = FunctionInvalidArgumentTypeException.class)
+
@Test(expected=ParserException.class)
public void testToRadiansWithWrongInputCharacter() {
+
public void testToLowerCaseWithWrongInputCharacter() {
Evaluator.getNumberResult("toRadians(a)", exerVar, fillIn);
+
Evaluator.evaluate("toLowerCase(ab)", exerciseVariableMap, fillInVariableMap);
 +
fail();
 
}
 
}
  
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
+
@Test(expected=FunctionInvalidNumberOfArgumentsException.class)
public void testToRadiansWithTwoArguments() {
+
public void testToLowerCaseWithTwoArguments() {
Evaluator.getNumberResult("toRadians(180, 90)", exerVar, fillIn);
+
Evaluator.evaluate("toLowerCase('A', 'B')", exerciseVariableMap, fillInVariableMap);
 +
fail();
 
}
 
}
  
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
+
@Test(expected=FunctionInvalidNumberOfArgumentsException.class)
public void testToRadiansWithThreeArguments() {
+
public void testToLowerCaseWithThreeArguments() {
Evaluator.getNumberResult("toRadians(45, 90, 180)", exerVar, fillIn);
+
Evaluator.evaluate("toLowerCase('A', 'B', 'C')", exerciseVariableMap, fillInVariableMap);
 +
fail();
 
}
 
}
  
@Test(expected = UndefinedExerciseVariableException.class)
+
@Test(expected=UndefinedExerciseVariableException.class)
public void testToRadiansWithMissingExerciseVariable() {
+
public void testToLowerCaseWithMissingExerciseVariable() {
Evaluator.getNumberResult("toRadians('[var=j]')", exerVar, fillIn);
+
Evaluator.evaluate("toLowerCase('[var=j]')", exerciseVariableMap, fillInVariableMap);
 +
fail();
 
}
 
}
  
@Test(expected = UndefinedFillInVariableException.class)
+
@Test(expected=UndefinedFillInVariableException.class)
public void testToRadiansWithMissingInput() {
+
public void testToLowerCaseWithMissingInput() {
Evaluator.getNumberResult("toRadians('[pos=42]')", exerVar, fillIn);
+
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();
}

Hinweise