BooleanNot: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Spobel (Diskussion | Beiträge) |
|||
Zeile 12: | Zeile 12: | ||
===Beispiele=== | ===Beispiele=== | ||
!0 --> | !0 --> True | ||
!1 --> | !1 --> False | ||
!(3+4==6) --> | !(3+4==6) --> True | ||
====JUnit Tests==== | ====JUnit Tests==== |
Version vom 4. Oktober 2017, 13:03 Uhr
Beschreibung
Die Funktion BooleanNot (!) testet ob eine Aussage wahr oder falsch ist.
Syntax
!a
Parameter
- a - boolean
Return Value
- Gibt einen Boolean zurück.
Beispiele
!0 --> True !1 --> False
!(3+4==6) --> True
JUnit Tests
[Anzeigen]
@Test
public void testBooleanNot1() {
assertEquals(1, Evaluator.getNumberResult("!0", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testBooleanNot2() {
assertEquals(0, Evaluator.getNumberResult("!1", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testBooleanNot3() {
assertEquals(true, Evaluator.getBooleanResult("!(3+4==6)", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanNotWithInput1() {
assertEquals(1, Evaluator.getNumberResult("![pos=1]", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testBooleanNotWithInput2() {
assertEquals(0, Evaluator.getNumberResult("![pos=2]", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testBooleanNotWithVariables1() {
assertEquals(1, Evaluator.getNumberResult("![var=a]", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testBooleanNotWithVariables2() {
assertEquals(0, Evaluator.getNumberResult("![var=b]", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testBooleanNotWithExpressions1() {
assertEquals(0, Evaluator.getNumberResult("!!0", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testBooleanNotWithExpressions2() {
assertEquals(1, Evaluator.getNumberResult("!!!0", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testBooleanNotWithWrongInputCharacter() {
Evaluator.getNumberResult("!'a'", exerciseVariableMap, fillInVariableMap);
fail();
}
Hinweise
- Wenn der Boolean b true ist gibt !b false zurück.