Acos: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Spobel (Diskussion | Beiträge) (→Syntax) |
Spobel (Diskussion | Beiträge) |
||
Zeile 12: | Zeile 12: | ||
===Beispiele=== | ===Beispiele=== | ||
acos( | acos(1) --> returns 0 | ||
====JUnit Tests==== | ====JUnit Tests==== |
Version vom 4. Oktober 2017, 12:49 Uhr
Beschreibung
Der Arkuskosinus wird durch die Funktion acos beschrieben. Sie erwartet einen Parameter und gibt den Wert an der Stelle zurück.
Syntax
acos(Gleitkommazahl zahl)
Parameter
- zahl - Ein Zahlenwert zwischen '-1' und '1'.
Return Value
- Gibt den Wert des Arkuskosinus an der Stelle zurück.
Beispiele
acos(1) --> returns 0
JUnit Tests
[Anzeigen]
private double PI = Math.PI;
@Test
public void testAcos1() {
assertEquals(0, Evaluator.getNumberResult("acos('1')", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAcos2() {
assertEquals(PI, Evaluator.getNumberResult("acos('-1')", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAcos3() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos('0')", exerciseVariableMap, fillInVariableMap), 0.000001);
}
@Test
public void testAcos4() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos('0')", exerciseVariableMap, fillInVariableMap), 0.000001);
}
@Test
public void testAcos5() {
assertEquals(0.795398830184144, Evaluator.getNumberResult("acos(0.7)", exerciseVariableMap, fillInVariableMap),
0.0);
}
@Test
public void testAcosWithInput1() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos([pos=1])", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testAcosWithInput2() {
assertEquals(0, Evaluator.getNumberResult("acos([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAcosWithInput3() {
assertEquals(PI, Evaluator.getNumberResult("acos([pos=3])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAcosWithVariables1() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos([var=a])", exerciseVariableMap, fillInVariableMap),
0.000001);
}
@Test
public void testAcosWithVariables2() {
assertEquals(0, Evaluator.getNumberResult("acos([var=b])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAcosWithVariables3() {
assertEquals(PI, Evaluator.getNumberResult("acos([var=c])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAcosWithExpressions1() {
assertEquals(0.861722668365136,
Evaluator.getNumberResult("acos(acos(acos(0.7)))", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAcosWithExpressions2() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos(acos(1))", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void TestAcosWithONECharacter() {
Evaluator.getNumberResult("acos(a)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAcosWithEmptyStringArgument() {
Evaluator.getNumberResult("acos('')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testAcosWithEmptyArgument() {
Evaluator.getNumberResult("acos()", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testAcosWithoutExerciseVariable() {
Evaluator.getNumberResult("acos('[var=j]')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedFillInVariableException.class)
public void testAcosWithoutInput() {
Evaluator.getNumberResult("acos('[pos=42]')", exerciseVariableMap, fillInVariableMap);
fail();
}