Acos: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 17: | Zeile 17: | ||
<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 double PI = Math.PI; | ||
public void | |||
@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 | @Test | ||
public void | public void testAcosWithVariables2() { | ||
assertEquals(0, Evaluator.getNumberResult("acos([var=b])", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAcosWithVariables3() { | ||
assertEquals(PI, Evaluator.getNumberResult("acos([var=c])", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAcosWithExpressions1() { | ||
assertEquals(0.861722668365136, | |||
Evaluator.getNumberResult("acos(acos(acos(0.7)))", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAcosWithExpressions2() { | ||
assertEquals(PI / 2, Evaluator.getNumberResult("acos(acos(1))", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void TestAcosWithONECharacter(){ | public void TestAcosWithONECharacter() { | ||
Evaluator.getNumberResult("acos(a)", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void testAcosWithEmptyStringArgument() { | public void testAcosWithEmptyStringArgument() { | ||
Evaluator.getNumberResult("acos('')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testAcosWithEmptyArgument() { | public void testAcosWithEmptyArgument() { | ||
Evaluator.getNumberResult("acos()", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testAcosWithoutExerciseVariable() { | public void testAcosWithoutExerciseVariable() { | ||
Evaluator.getNumberResult("acos('[var=j]')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testAcosWithoutInput() { | public void testAcosWithoutInput() { | ||
Evaluator.getNumberResult("acos('[pos=42]')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 18. September 2017, 10:20 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(String 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();
}