ToDegree: 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"> | ||
@ | @BeforeClass | ||
public void beforeTest(){ | public static void beforeTest() { | ||
OMOBJ piFourth = new OMOBJ(); | |||
OMOBJ piHalf = new OMOBJ(); | |||
OMOBJ pi = new OMOBJ(); | |||
OMOBJ twoPi = new OMOBJ(); | |||
OMOBJ one = new OMOBJ(); | |||
piFourth.setOMF(OMCreator.createOMF(PI / 4)); | |||
piHalf.setOMF(OMCreator.createOMF(PI / 2)); | |||
pi.setOMF(OMCreator.createOMF(PI)); | |||
twoPi.setOMF(OMCreator.createOMF(2 * PI)); | |||
one.setOMI(OMCreator.createOMI(1)); | |||
fillIn.put(45, piFourth); | |||
fillIn.put(90, piHalf); | |||
fillIn.put(1, one); | |||
exerVar.put("degc", pi); | |||
exerVar.put("degd", twoPi); | |||
exerVar.put("b", one); | |||
} | } | ||
@Test public void | @Test | ||
public void testToDegrees1() { | |||
assertEquals(540, Evaluator.getNumberResult("toDegrees(" + 3 * PI + ")", exerVar, fillIn), 0); | |||
} | } | ||
@Test public void | @Test | ||
public void testToDegrees2() { | |||
assertEquals(360, Evaluator.getNumberResult("toDegrees(" + 2 * PI + ")", exerVar, fillIn), 0); | |||
} | } | ||
@Test public void | @Test | ||
public void testToDegrees3() { | |||
assertEquals(180, Evaluator.getNumberResult("toDegrees(" + PI + ")", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testToDegrees4() { | ||
assertEquals(-180, Evaluator.getNumberResult("toDegrees(" + -PI + ")", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testToDegrees5() { | ||
assertEquals(90, Evaluator.getNumberResult("toDegrees(" + PI / 2 + ")", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testToDegrees6() { | ||
assertEquals(45, Evaluator.getNumberResult("toDegrees(" + PI / 4 + ")", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testToDegrees7() { | ||
assertEquals(180 / PI, Evaluator.getNumberResult("toDegrees(1)", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testToDegreesWithInput1() { | ||
assertEquals(90, Evaluator.getNumberResult("toDegrees('[pos=90]')", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testToDegreesWithInput2() { | ||
assertEquals(45, Evaluator.getNumberResult("toDegrees('[pos=45]')", exerVar, fillIn), 0); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test | ||
public void testToDegreesWithMissingInput(){ | public void testToDegreesWithInput3() { | ||
assertEquals(180 / PI, Evaluator.getNumberResult("toDegrees('[pos=1]')", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testToDegreesWithVariables1() { | |||
assertEquals(360, Evaluator.getNumberResult("toDegrees('[var=degd]')", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testToDegreesWithVariables2() { | |||
assertEquals(180, Evaluator.getNumberResult("toDegrees('[var=degc]')", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testToDegreesWithVariables3() { | |||
assertEquals(180 / PI, Evaluator.getNumberResult("toDegrees('[var=b]')", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testToDegreesWithVariables4() { | |||
assertEquals(180, Evaluator.getNumberResult("toDegrees('[var=PI]')", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testToDegreesWithPointNumbers1() { | |||
assertEquals(.2 * 180 / (PI), Evaluator.getNumberResult("toDegrees(0.2)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testToDegreesWithPointNumbers2() { | |||
assertEquals(.1 * 180 / (-PI), Evaluator.getNumberResult("toDegrees(-0.1)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testToDegreesWithExpressions1() { | |||
assertEquals(0, Evaluator.getNumberResult("toDegrees(toDegrees(0))", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testToDegreesWithExpressions2() { | |||
assertEquals(0, Evaluator.getNumberResult("toDegrees(toDegrees(toDegrees(0)))", exerVar, fillIn), 0); | |||
} | |||
@Test(expected = FunctionInvalidArgumentTypeException.class) | |||
public void testToDegreesWithWrongInputCharacter() { | |||
Evaluator.getNumberResult("toDegrees(a)", exerVar, fillIn); | |||
} | |||
@Test(expected = FunctionInvalidNumberOfArgumentsException.class) | |||
public void testToDegreesWithTwoArguments() { | |||
Evaluator.getNumberResult("toDegrees(4, 3)", exerVar, fillIn); | |||
} | |||
@Test(expected = FunctionInvalidNumberOfArgumentsException.class) | |||
public void testToDegreesWithThreeArguments() { | |||
Evaluator.getNumberResult("toDegrees(2, 3, 4)", exerVar, fillIn); | |||
} | |||
@Test(expected = UndefinedExerciseVariableException.class) | |||
public void testToDegreesWithMissingExerciseVariable() { | |||
Evaluator.getNumberResult("toDegrees('[var=j]')", exerVar, fillIn); | |||
} | |||
@Test(expected = UndefinedFillInVariableException.class) | |||
public void testToDegreesWithMissingInput() { | |||
Evaluator.getNumberResult("toDegrees('[pos=42]')", exerVar, fillIn); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 19. September 2017, 07:46 Uhr
Beschreibung
Die Funktion toDegrees wandelt Radiant-Werte in Grad um. Die Funktion erwartet einen Radiant und gibt den entsprechenden Grad zurück.
Syntax
toDegrees(float radiant)
Parameter
- radiant - der umzuwandelnde Radiant-Wert
Return Value
- Gibt den Radiant-Wert in Grad zurück
Beispiele
Standardfälle
toDegrees(3.14159) --> returns 180 toDegrees(6.28319) --> returns 360
Benutzung mit Variablen
toDegrees([pos=1]) toDegrees([var=a])
JUnit Tests
[Anzeigen]