Sin: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 19: | Zeile 19: | ||
<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() { | ||
fillInVariableMap.put(2, OMCreator.createOMOBJ(OMSymbol.NUMS1_PI)); | |||
} | } | ||
@Test | |||
public void testSin1() { | |||
assertEquals(0, Evaluator.getNumberResult("sin('0')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | @Test | ||
public void | public void testSin2() { | ||
assertEquals(1, Evaluator.getNumberResult("sin('[var=PI]/2')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testSin3() { | ||
assertEquals(-1, Evaluator.getNumberResult("sin('-[var=PI]/2')", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testSin4() { | ||
assertEquals(0, Evaluator.getNumberResult("sin('[var=PI]')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testSin5() { | ||
assertEquals(0, Evaluator.getNumberResult("sin('-[var=PI]')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testSinWithInput1() { | ||
assertEquals(0, Evaluator.getNumberResult("sin('[pos=1]')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test(expected= | @Test | ||
public void testSinWithInput2() { | |||
assertEquals(1, Evaluator.getNumberResult("sin('[pos=2]/2')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testSinWithVariables1() { | |||
assertEquals(0, Evaluator.getNumberResult("sin('[var=a]')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testSinWithVariables2() { | |||
assertEquals(1, Evaluator.getNumberResult("sin('[var=PI]/2')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testSinWithExpressions1() { | |||
assertEquals(0, Evaluator.getNumberResult("sin(sin(0))", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testSinWithExpressions2() { | |||
assertEquals(0, Evaluator.getNumberResult("sin(sin(sin(0)))", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test(expected = FunctionInvalidArgumentTypeException.class) | |||
public void testSinWithONECharacter() { | |||
Evaluator.getNumberResult("sin(a)", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | |||
@Test(expected = FunctionInvalidArgumentTypeException.class) | |||
public void testSinWithEmptyStringArgument() { | public void testSinWithEmptyStringArgument() { | ||
Evaluator.getNumberResult("sin('')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testSinWithEmptyArgument() { | public void testSinWithEmptyArgument() { | ||
Evaluator.getNumberResult("sin()", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testSinWithoutExerciseVariable() { | public void testSinWithoutExerciseVariable() { | ||
Evaluator.getNumberResult("sin('[var=j]')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testSinWithoutInput() { | public void testSinWithoutInput() { | ||
Evaluator.getNumberResult("sin('[pos=42]')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 19. September 2017, 07:42 Uhr
Beschreibung
Der Sinus wird durch die sin-Funktion beschrieben. Sie erwartet einen Parameter und gibt einen Wert zurück.
Syntax
sin(String zeichenkette)
Parameter
- zeichenkette - ein Wert im Bogenmaß
Return Value
- Der Rückgabewert der Sinusfunktion.
Beispiele
sin('Pi') --> returns 0
sin('Pi/2') --> returns 1
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() {
fillInVariableMap.put(2, OMCreator.createOMOBJ(OMSymbol.NUMS1_PI));
}
@Test
public void testSin1() {
assertEquals(0, Evaluator.getNumberResult("sin('0')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSin2() {
assertEquals(1, Evaluator.getNumberResult("sin('[var=PI]/2')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSin3() {
assertEquals(-1, Evaluator.getNumberResult("sin('-[var=PI]/2')", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testSin4() {
assertEquals(0, Evaluator.getNumberResult("sin('[var=PI]')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSin5() {
assertEquals(0, Evaluator.getNumberResult("sin('-[var=PI]')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSinWithInput1() {
assertEquals(0, Evaluator.getNumberResult("sin('[pos=1]')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSinWithInput2() {
assertEquals(1, Evaluator.getNumberResult("sin('[pos=2]/2')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSinWithVariables1() {
assertEquals(0, Evaluator.getNumberResult("sin('[var=a]')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSinWithVariables2() {
assertEquals(1, Evaluator.getNumberResult("sin('[var=PI]/2')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSinWithExpressions1() {
assertEquals(0, Evaluator.getNumberResult("sin(sin(0))", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testSinWithExpressions2() {
assertEquals(0, Evaluator.getNumberResult("sin(sin(sin(0)))", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testSinWithONECharacter() {
Evaluator.getNumberResult("sin(a)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testSinWithEmptyStringArgument() {
Evaluator.getNumberResult("sin('')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testSinWithEmptyArgument() {
Evaluator.getNumberResult("sin()", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testSinWithoutExerciseVariable() {
Evaluator.getNumberResult("sin('[var=j]')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedFillInVariableException.class)
public void testSinWithoutInput() {
Evaluator.getNumberResult("sin('[pos=42]')", exerciseVariableMap, fillInVariableMap);
fail();
}
Hinweise
- Die Funktion braucht den Wert im Bogenmaß, ggf. muss man den Gradmaß vorher umrechnen.