Floor: 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 zero = new OMOBJ(); | |||
OMOBJ twoThree = new OMOBJ(); | |||
OMOBJ mFourOne = new OMOBJ(); | |||
zero.setOMI(OMCreator.createOMI(0)); | |||
twoThree.setOMF(OMCreator.createOMF(2.3)); | |||
mFourOne.setOMF(OMCreator.createOMF(-4.156665)); | |||
fillIn.put(1, zero); | |||
fillIn.put(2, twoThree); | |||
fillIn.put(3, mFourOne); | |||
exerVar.put("a", zero); | |||
exerVar.put("b", twoThree); | |||
exerVar.put("c", mFourOne); | |||
} | |||
@Test | |||
public void testFloor1() { | |||
assertEquals(5, Evaluator.getNumberResult("floor(5.4)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testFloor2() { | |||
assertEquals(5, Evaluator.getNumberResult("floor(5.0)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testFloor3() { | |||
assertEquals(0, Evaluator.getNumberResult("floor(0)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testFloor4() { | |||
assertEquals(-6, Evaluator.getNumberResult("floor(-5.4343664)", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testFloorWithInput1() { | |||
assertEquals(0, Evaluator.getNumberResult("floor([pos=1])", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testFloorWithInput2() { | |||
assertEquals(2, Evaluator.getNumberResult("floor([pos=2])", exerVar, fillIn), 0); | |||
} | |||
@Test | |||
public void testFloorWithInput3() { | |||
assertEquals(-5, Evaluator.getNumberResult("floor([pos=3])", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testFloorWithVariables1() { | ||
assertEquals(0, Evaluator.getNumberResult("floor([var=a])", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testFloorWithVariables2() { | ||
assertEquals(2, Evaluator.getNumberResult("floor([var=b])", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testFloorWithVariables3() { | ||
assertEquals(-5, Evaluator.getNumberResult("floor([var=c])", exerVar, fillIn), 0); | |||
} | } | ||
@Test | @Test | ||
public void testFloorWithExpressions(){ | public void testFloorWithExpressions() { | ||
assertEquals(5, Evaluator.getNumberResult("floor(floor(5.1354))", exerVar, fillIn), 0); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void testFloorWithWrongInputCharacter(){ | public void testFloorWithWrongInputCharacter() { | ||
Evaluator.getNumberResult("floor(a)", exerVar, fillIn); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testFloorWithTwoArguments(){ | public void testFloorWithTwoArguments() { | ||
Evaluator.getNumberResult("floor(7.4321, 3)", exerVar, fillIn); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testFloorWithThreeArguments(){ | public void testFloorWithThreeArguments() { | ||
Evaluator.getNumberResult("floor(1.434321, 5, 7)", exerVar, fillIn); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testFloorWithMissingExerciseVariable(){ | public void testFloorWithMissingExerciseVariable() { | ||
Evaluator.getNumberResult("floor([var=j])", exerVar, fillIn); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testFloorWithMissingInput(){ | public void testFloorWithMissingInput() { | ||
Evaluator.getNumberResult("floor([pos=42])", exerVar, fillIn); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 18. September 2017, 11:20 Uhr
Beschreibung
Die Funktion floor rundet eine rationale Zahl auf die nächstgrößere ganze Zahl ab. Die Funktion erwartet eine Zahl als Parameter und gibt eine Zahl zurück.
Syntax
floor(float zahl)
Parameter
- zahl - eine abzurundende rationale Zahl
Return Value
- Gibt eine Ganzzahl zurück.
Beispiele
Standardfälle
floor('7.3') --> returns 7 floor('-2.4') --> returns -3
Benutzung mit Variablen
floor('[pos=1]') floor('[var=a]')
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() {
OMOBJ zero = new OMOBJ();
OMOBJ twoThree = new OMOBJ();
OMOBJ mFourOne = new OMOBJ();
zero.setOMI(OMCreator.createOMI(0));
twoThree.setOMF(OMCreator.createOMF(2.3));
mFourOne.setOMF(OMCreator.createOMF(-4.156665));
fillIn.put(1, zero);
fillIn.put(2, twoThree);
fillIn.put(3, mFourOne);
exerVar.put("a", zero);
exerVar.put("b", twoThree);
exerVar.put("c", mFourOne);
}
@Test
public void testFloor1() {
assertEquals(5, Evaluator.getNumberResult("floor(5.4)", exerVar, fillIn), 0);
}
@Test
public void testFloor2() {
assertEquals(5, Evaluator.getNumberResult("floor(5.0)", exerVar, fillIn), 0);
}
@Test
public void testFloor3() {
assertEquals(0, Evaluator.getNumberResult("floor(0)", exerVar, fillIn), 0);
}
@Test
public void testFloor4() {
assertEquals(-6, Evaluator.getNumberResult("floor(-5.4343664)", exerVar, fillIn), 0);
}
@Test
public void testFloorWithInput1() {
assertEquals(0, Evaluator.getNumberResult("floor([pos=1])", exerVar, fillIn), 0);
}
@Test
public void testFloorWithInput2() {
assertEquals(2, Evaluator.getNumberResult("floor([pos=2])", exerVar, fillIn), 0);
}
@Test
public void testFloorWithInput3() {
assertEquals(-5, Evaluator.getNumberResult("floor([pos=3])", exerVar, fillIn), 0);
}
@Test
public void testFloorWithVariables1() {
assertEquals(0, Evaluator.getNumberResult("floor([var=a])", exerVar, fillIn), 0);
}
@Test
public void testFloorWithVariables2() {
assertEquals(2, Evaluator.getNumberResult("floor([var=b])", exerVar, fillIn), 0);
}
@Test
public void testFloorWithVariables3() {
assertEquals(-5, Evaluator.getNumberResult("floor([var=c])", exerVar, fillIn), 0);
}
@Test
public void testFloorWithExpressions() {
assertEquals(5, Evaluator.getNumberResult("floor(floor(5.1354))", exerVar, fillIn), 0);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testFloorWithWrongInputCharacter() {
Evaluator.getNumberResult("floor(a)", exerVar, fillIn);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testFloorWithTwoArguments() {
Evaluator.getNumberResult("floor(7.4321, 3)", exerVar, fillIn);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testFloorWithThreeArguments() {
Evaluator.getNumberResult("floor(1.434321, 5, 7)", exerVar, fillIn);
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testFloorWithMissingExerciseVariable() {
Evaluator.getNumberResult("floor([var=j])", exerVar, fillIn);
}
@Test(expected = UndefinedFillInVariableException.class)
public void testFloorWithMissingInput() {
Evaluator.getNumberResult("floor([pos=42])", exerVar, fillIn);
}