Ceil: 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 fourFive = new OMOBJ(); | |||
fourFive.setOMF(OMCreator.createOMF(4.5)); | |||
fillIn.put(1, fourFive); | |||
exerVar.put("a", fourFive); | |||
} | |||
@Test | |||
public void testCeil1() { | |||
assertEquals(1, Evaluator.getNumberResult("ceil('0.5')", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testCeil2() { | |||
assertEquals(-3, Evaluator.getNumberResult("ceil(-3.000001)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testCeil3() { | |||
assertEquals(1, Evaluator.getNumberResult("ceil(1)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testCeil4() { | |||
assertEquals(0, Evaluator.getNumberResult("ceil(0)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testCeilWithInput1() { | |||
assertEquals(1, Evaluator.getNumberResult("ceil('0.5')", exerVar, fillIn), 0); | |||
} | } | ||
@Test public void | @Test | ||
public void testCeilWithInput2() { | |||
assertEquals(5, Evaluator.getNumberResult("ceil('[pos=1]')", exerVar, fillIn), 0); | |||
} | } | ||
@Test public void | @Test | ||
public void testCeilWithVariables1() { | |||
assertEquals(1, Evaluator.getNumberResult("ceil('0.5')", exerVar, fillIn), 0); | |||
} | } | ||
@Test public void | @Test | ||
public void testCeilWithVariables2() { | |||
assertEquals(5, Evaluator.getNumberResult("ceil('[var=a]')", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testCeilWithExpressions1() { | |||
assertEquals(-2, Evaluator.getNumberResult("ceil(ceil(-2.2))", exerVar, fillIn), 0); | |||
} | } | ||
@Test public void | @Test | ||
public void testCeilWithExpressions2() { | |||
assertEquals(2, Evaluator.getNumberResult("ceil(ceil(ceil(1.11)))", exerVar, fillIn), 0); | |||
} | } | ||
@Test (expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) // (expected=InvalidEvaluatorFunctionArgumentException.class) | ||
public void | public void testCeilWithWrongInputCharacter() { | ||
Evaluator.getNumberResult("ceil(a)", exerVar, fillIn); | |||
} | } | ||
@Test (expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void | public void testCeilWithTwoArguments() { | ||
Evaluator.getNumberResult("ceil(2.2, 3.3)", exerVar, fillIn); | |||
} | } | ||
@Test (expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void | public void testCeilWithThreeArguments() { | ||
Evaluator.getNumberResult("ceil(2.2, 3.3, -1.1)", exerVar, fillIn); | |||
} | } | ||
@Test (expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void | public void testCeilWithMissingExcerciseVariable() { | ||
Evaluator.getNumberResult("ceil('[var=j]')", exerVar, fillIn); | |||
} | } | ||
@Test (expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void | public void testCeilWithMissingInput() { | ||
Evaluator.getNumberResult("ceil('[pos=42]')", exerVar, fillIn); | |||
} | } | ||
</syntaxhighlight > | </syntaxhighlight > |
Version vom 18. September 2017, 10:36 Uhr
Beschreibung
Die Funktion ceil rundet eine rationale Zahl auf die nächstgrößere ganze Zahl auf. Die Funktion erwartet eine Zahl als Parameter und gibt eine Zahl zurück.
Syntax
ceil(float zahl)
Parameter
- zahl - eine aufzurundende rationale Zahl
Return Value
- Gibt eine Ganzzahl zurück
Beispiele
Standardfälle
ceil('7.3') --> returns 8 ceil('-2.4') --> returns -2
Benutzung von Variablen
ceil('[pos=1]') ceil('[var=a]')
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() {
OMOBJ fourFive = new OMOBJ();
fourFive.setOMF(OMCreator.createOMF(4.5));
fillIn.put(1, fourFive);
exerVar.put("a", fourFive);
}
@Test
public void testCeil1() {
assertEquals(1, Evaluator.getNumberResult("ceil('0.5')", exerVar, fillIn), 0);
}
@Test
public void testCeil2() {
assertEquals(-3, Evaluator.getNumberResult("ceil(-3.000001)", exerVar, fillIn), 0);
}
@Test
public void testCeil3() {
assertEquals(1, Evaluator.getNumberResult("ceil(1)", exerVar, fillIn), 0);
}
@Test
public void testCeil4() {
assertEquals(0, Evaluator.getNumberResult("ceil(0)", exerVar, fillIn), 0);
}
@Test
public void testCeilWithInput1() {
assertEquals(1, Evaluator.getNumberResult("ceil('0.5')", exerVar, fillIn), 0);
}
@Test
public void testCeilWithInput2() {
assertEquals(5, Evaluator.getNumberResult("ceil('[pos=1]')", exerVar, fillIn), 0);
}
@Test
public void testCeilWithVariables1() {
assertEquals(1, Evaluator.getNumberResult("ceil('0.5')", exerVar, fillIn), 0);
}
@Test
public void testCeilWithVariables2() {
assertEquals(5, Evaluator.getNumberResult("ceil('[var=a]')", exerVar, fillIn), 0);
}
@Test
public void testCeilWithExpressions1() {
assertEquals(-2, Evaluator.getNumberResult("ceil(ceil(-2.2))", exerVar, fillIn), 0);
}
@Test
public void testCeilWithExpressions2() {
assertEquals(2, Evaluator.getNumberResult("ceil(ceil(ceil(1.11)))", exerVar, fillIn), 0);
}
@Test(expected = FunctionInvalidArgumentTypeException.class) // (expected=InvalidEvaluatorFunctionArgumentException.class)
public void testCeilWithWrongInputCharacter() {
Evaluator.getNumberResult("ceil(a)", exerVar, fillIn);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testCeilWithTwoArguments() {
Evaluator.getNumberResult("ceil(2.2, 3.3)", exerVar, fillIn);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testCeilWithThreeArguments() {
Evaluator.getNumberResult("ceil(2.2, 3.3, -1.1)", exerVar, fillIn);
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testCeilWithMissingExcerciseVariable() {
Evaluator.getNumberResult("ceil('[var=j]')", exerVar, fillIn);
}
@Test(expected = UndefinedFillInVariableException.class)
public void testCeilWithMissingInput() {
Evaluator.getNumberResult("ceil('[pos=42]')", exerVar, fillIn);
}