ToRadian: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
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; | ||
public void beforeTest(){ | |||
@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 | @Test | ||
public void testToRadiansWithInput2() { | |||
assertEquals(0, Evaluator.getNumberResult("toRadians('[pos=2]')", exerVar, fillIn), 0); | |||
} | } | ||
@Test public void | @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 | @Test | ||
public void testToRadiansWithPointNumbers2() { | |||
assertEquals((-PI * .1) / 180, Evaluator.getNumberResult("toRadians(-0.1)", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testToRadiansWithExpressions1() { | ||
assertEquals(0, Evaluator.getNumberResult("toRadians(toRadians(0))", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testToRadiansWithExpressions2() { | ||
assertEquals(0, Evaluator.getNumberResult("toRadians(toRadians(toRadians(0)))", exerVar, fillIn), 0); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void testToRadiansWithWrongInputCharacter(){ | public void testToRadiansWithWrongInputCharacter() { | ||
Evaluator.getNumberResult("toRadians(a)", exerVar, fillIn); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testToRadiansWithTwoArguments(){ | public void testToRadiansWithTwoArguments() { | ||
Evaluator.getNumberResult("toRadians(180, 90)", exerVar, fillIn); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testToRadiansWithThreeArguments(){ | public void testToRadiansWithThreeArguments() { | ||
Evaluator.getNumberResult("toRadians(45, 90, 180)", exerVar, fillIn); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testToRadiansWithMissingExerciseVariable(){ | public void testToRadiansWithMissingExerciseVariable() { | ||
Evaluator.getNumberResult("toRadians('[var=j]')", exerVar, fillIn); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testToRadiansWithMissingInput(){ | public void testToRadiansWithMissingInput() { | ||
Evaluator.getNumberResult("toRadians('[pos=42]')", exerVar, fillIn); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Version vom 19. September 2017, 07:47 Uhr
Beschreibung
Die Funktion toRadians wandelt Grad-Werte in Radiant um. Die Funktion erwartet einen Grad-Wert und gibt den entsprechenden Radiant zurück.
Syntax
toRadians(float grad)
Parameter
- grad - der umzuwandelnde Grad-Wert
Return Value
- Gibt den Grad-Wert als Radiant zurück
Beispiele
Standardfälle
toRadians(180) --> returns 3.14159 toRadians(360) --> returns 6.28319
Benutzung mit Variablen
toRadians([pos=1]) toRadians([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);
}