ToLowerCase: Unterschied zwischen den Versionen

Aus JACK Wiki
Wechseln zu: Navigation, Suche
(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">
@Before
+
private static double PI = Math.PI;
public void beforeTest(){
 
  placeFillInVariable(1, OMParser.parse("HELLO"));
 
  placeFillInVariable(2, OMParser.parse("HELLO3"));
 
  
  placeExerciseVariable("a", OMParser.parse("HELLO"));
+
@BeforeClass
  placeExerciseVariable("b", OMParser.parse("HELLO3"));
+
public static void beforeTest() {
 +
OMOBJ to180 = new OMOBJ();
 +
OMOBJ zero = new OMOBJ();
 +
to180.setOMI(OMCreator.createOMI(180));
 +
zero.setOMI(OMCreator.createOMI(0));
 +
 
 +
fillIn.put(1, to180);
 +
fillIn.put(2, zero);
 +
 
 +
exerVar.put("a", to180);
 +
exerVar.put("b", zero);
 
}
 
}
+
 
@Test public void testToLowerCase(){
+
@Test
  assertTrue("'abcdefghijklmnopqrstuvwxyz'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase('ABCDEFGHIJKLMNOPQRSTUVWXYZ')")));
+
public void testToRadians1() {
  assertTrue("'1234567890.!\"§$%&/()=?'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase('1234567890.!\"§$%&/()=?')")));
+
assertEquals(PI, Evaluator.getNumberResult("toRadians(180)", exerVar, fillIn), 0);
  assertTrue("'abcdefghijklmnopqrstuvwxyz'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase('abcdefghijklmnopqrstuvwxyz')")));
 
  assertTrue("''".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase('')")));
 
  assertTrue("' '".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase(' ')")));
 
 
}
 
}
+
 
 +
@Test
 +
public void testToRadians2() {
 +
assertEquals(2 * PI, Evaluator.getNumberResult("toRadians(360)", exerVar, fillIn), 0);
 +
}
 +
 
 +
@Test
 +
public void testToRadians3() {
 +
assertEquals(3 * PI, Evaluator.getNumberResult("toRadians(540)", exerVar, fillIn), 0);
 +
}
 +
 
 
@Test
 
@Test
public void testToLowerCaseWithInput(){
+
public void testToRadians4() {
  assertTrue("'hello'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase('[pos=1]')")));
+
assertEquals(PI / 2, Evaluator.getNumberResult("toRadians(90)", exerVar, fillIn), 0);
  assertTrue("'hello3'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase('[pos=2]')")));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void TestToLowerCaseWithVariables(){
+
public void testToRadians5() {
  assertTrue("'hello'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase('[var=a]')")));
+
assertEquals(-PI, Evaluator.getNumberResult("toRadians(-180)", exerVar, fillIn), 0);
  assertTrue("'hello3'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase('[var=b]')")));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testToLowerCaseWithExpressions(){
+
public void testToRadians6() {
  assertTrue("'a'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase(toLowerCase('A'))")));
+
assertEquals(0, Evaluator.getNumberResult("toRadians(0)", exerVar, fillIn), 0);
  assertTrue("'a'".equals(getEvaluator().getResultAsEvaluatorString("toLowerCase(toLowerCase(toLowerCase('A')))")));
 
 
}
 
}
+
 
@Test(expected=InvalidEvaluatorFunctionArgumentException.class)
+
@Test
public void testToLowerCaseWithWrongInputCharacter(){
+
public void testToRadiansWithInput1() {
  getEvaluator().getResultAsEvaluatorString("toLowerCase(a)");
+
assertEquals(PI, Evaluator.getNumberResult("toRadians('[pos=1]')", exerVar, fillIn), 0);
 
}
 
}
+
 
@Test(expected=UnsupportedEvaluatorFunctionException.class)
+
@Test
public void testToLowerCaseWithTwoArguments(){
+
public void testToRadiansWithInput2() {
  getEvaluator().getResultAsEvaluatorString("toLowerCase('A', 'B')");
+
assertEquals(0, Evaluator.getNumberResult("toRadians('[pos=2]')", exerVar, fillIn), 0);
 
}
 
}
+
 
@Test(expected=UnsupportedEvaluatorFunctionException.class)
+
@Test
public void testToLowerCaseWithThreeArguments(){
+
public void testToRadiansWithVariables1() {
  getEvaluator().getResultAsEvaluatorString("toLowerCase('A', 'B', 'C')");
+
assertEquals(PI, Evaluator.getNumberResult("toRadians('[var=a]')", exerVar, fillIn), 0);
 +
 
 
}
 
}
+
 
@Test(expected=UndefinedExerciseVariableException.class)
+
@Test
public void testToLowerCaseWithMissingExerciseVariable(){
+
public void testToRadiansWithVariables2() {
  getEvaluator().getResultAsEvaluatorString("toLowerCase('[var=j]')");
+
assertEquals(0, Evaluator.getNumberResult("toRadians('[var=b]')", exerVar, fillIn), 0);
 
}
 
}
+
 
@Test(expected=UndefinedFillInVariableException.class)
+
@Test
public void testToLowerCaseWithMissingInput(){
+
public void testToRadiansWithPointNumbers1() {
  getEvaluator().getResultAsEvaluatorString("toLowerCase('[pos=42]')");
+
assertEquals((PI * .2) / 180, Evaluator.getNumberResult("toRadians(0.2)", exerVar, fillIn), 0);
 +
}
 +
 
 +
@Test
 +
public void testToRadiansWithPointNumbers2() {
 +
assertEquals((-PI * .1) / 180, Evaluator.getNumberResult("toRadians(-0.1)", exerVar, fillIn), 0);
 +
}
 +
 
 +
@Test
 +
public void testToRadiansWithExpressions1() {
 +
assertEquals(0, Evaluator.getNumberResult("toRadians(toRadians(0))", exerVar, fillIn), 0);
 +
}
 +
 
 +
@Test
 +
public void testToRadiansWithExpressions2() {
 +
assertEquals(0, Evaluator.getNumberResult("toRadians(toRadians(toRadians(0)))", exerVar, fillIn), 0);
 +
}
 +
 
 +
@Test(expected = FunctionInvalidArgumentTypeException.class)
 +
public void testToRadiansWithWrongInputCharacter() {
 +
Evaluator.getNumberResult("toRadians(a)", exerVar, fillIn);
 +
}
 +
 
 +
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
 +
public void testToRadiansWithTwoArguments() {
 +
Evaluator.getNumberResult("toRadians(180, 90)", exerVar, fillIn);
 +
}
 +
 
 +
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
 +
public void testToRadiansWithThreeArguments() {
 +
Evaluator.getNumberResult("toRadians(45, 90, 180)", exerVar, fillIn);
 +
}
 +
 
 +
@Test(expected = UndefinedExerciseVariableException.class)
 +
public void testToRadiansWithMissingExerciseVariable() {
 +
Evaluator.getNumberResult("toRadians('[var=j]')", exerVar, fillIn);
 +
}
 +
 
 +
@Test(expected = UndefinedFillInVariableException.class)
 +
public void testToRadiansWithMissingInput() {
 +
Evaluator.getNumberResult("toRadians('[pos=42]')", exerVar, fillIn);
 
}
 
}
 
</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]

private static double PI = Math.PI;

@BeforeClass
public static void beforeTest() {
	OMOBJ to180 = new OMOBJ();
	OMOBJ zero = new OMOBJ();
	to180.setOMI(OMCreator.createOMI(180));
	zero.setOMI(OMCreator.createOMI(0));

	fillIn.put(1, to180);
	fillIn.put(2, zero);

	exerVar.put("a", to180);
	exerVar.put("b", zero);
}

@Test
public void testToRadians1() {
	assertEquals(PI, Evaluator.getNumberResult("toRadians(180)", exerVar, fillIn), 0);
}

@Test
public void testToRadians2() {
	assertEquals(2 * PI, Evaluator.getNumberResult("toRadians(360)", exerVar, fillIn), 0);
}

@Test
public void testToRadians3() {
	assertEquals(3 * PI, Evaluator.getNumberResult("toRadians(540)", exerVar, fillIn), 0);
}

@Test
public void testToRadians4() {
	assertEquals(PI / 2, Evaluator.getNumberResult("toRadians(90)", exerVar, fillIn), 0);
}

@Test
public void testToRadians5() {
	assertEquals(-PI, Evaluator.getNumberResult("toRadians(-180)", exerVar, fillIn), 0);
}

@Test
public void testToRadians6() {
	assertEquals(0, Evaluator.getNumberResult("toRadians(0)", exerVar, fillIn), 0);
}

@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
public void testToRadiansWithVariables2() {
	assertEquals(0, Evaluator.getNumberResult("toRadians('[var=b]')", exerVar, fillIn), 0);
}

@Test
public void testToRadiansWithPointNumbers1() {
	assertEquals((PI * .2) / 180, Evaluator.getNumberResult("toRadians(0.2)", exerVar, fillIn), 0);
}

@Test
public void testToRadiansWithPointNumbers2() {
	assertEquals((-PI * .1) / 180, Evaluator.getNumberResult("toRadians(-0.1)", exerVar, fillIn), 0);
}

@Test
public void testToRadiansWithExpressions1() {
	assertEquals(0, Evaluator.getNumberResult("toRadians(toRadians(0))", exerVar, fillIn), 0);
}

@Test
public void testToRadiansWithExpressions2() {
	assertEquals(0, Evaluator.getNumberResult("toRadians(toRadians(toRadians(0)))", exerVar, fillIn), 0);
}

@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testToRadiansWithWrongInputCharacter() {
	Evaluator.getNumberResult("toRadians(a)", exerVar, fillIn);
}

@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testToRadiansWithTwoArguments() {
	Evaluator.getNumberResult("toRadians(180, 90)", exerVar, fillIn);
}

@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testToRadiansWithThreeArguments() {
	Evaluator.getNumberResult("toRadians(45, 90, 180)", exerVar, fillIn);
}

@Test(expected = UndefinedExerciseVariableException.class)
public void testToRadiansWithMissingExerciseVariable() {
	Evaluator.getNumberResult("toRadians('[var=j]')", exerVar, fillIn);
}

@Test(expected = UndefinedFillInVariableException.class)
public void testToRadiansWithMissingInput() {
	Evaluator.getNumberResult("toRadians('[pos=42]')", exerVar, fillIn);
}

Hinweise