BooleanNot: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 16: | Zeile 16: | ||
!(3+4==6) --> true | !(3+4==6) --> true | ||
====JUnit Tests==== | |||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed"> | |||
@Before | |||
public void beforeTest() { | |||
placeFillInVariable(1, OMParser.parse("0")); | |||
placeFillInVariable(2, OMParser.parse("1")); | |||
placeExerciseVariable("a", OMParser.parse("0")); | |||
placeExerciseVariable("b", OMParser.parse("1")); | |||
} | |||
@Test | |||
public void testBooleanNot() { | |||
assertTrue(1 == getEvaluator().getNumberResult("!0")); | |||
assertTrue(0 == getEvaluator().getNumberResult("!1")); | |||
assertEquals(true, getEvaluator().getBooleanResult("!(3+4==6)")); | |||
} | |||
@Test | |||
public void testBooleanNotWithInput() { | |||
assertTrue(1 == getEvaluator().getNumberResult("![pos=1]")); | |||
assertTrue(0 == getEvaluator().getNumberResult("![pos=2]")); | |||
} | |||
@Test | |||
public void testBooleanNotWithVariables() { | |||
assertTrue(1 == getEvaluator().getNumberResult("![var=a]")); | |||
assertTrue(0 == getEvaluator().getNumberResult("![var=b]")); | |||
} | |||
@Test | |||
public void testBooleanNotWithExpressions() { | |||
assertTrue(0 == getEvaluator().getNumberResult("!!0")); | |||
assertTrue(1 == getEvaluator().getNumberResult("!!!0")); | |||
} | |||
@Test(expected=UnsupportedUnaryOperatorException.class) | |||
public void testBooleanNotWithWrongInputCharacter() { | |||
getEvaluator().getNumberResult("!'a'"); | |||
} | |||
</syntaxhighlight> | |||
===Hinweise=== | ===Hinweise=== |
Version vom 21. Juni 2017, 10:29 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
@Before
public void beforeTest() {
placeFillInVariable(1, OMParser.parse("0"));
placeFillInVariable(2, OMParser.parse("1"));
placeExerciseVariable("a", OMParser.parse("0"));
placeExerciseVariable("b", OMParser.parse("1"));
}
@Test
public void testBooleanNot() {
assertTrue(1 == getEvaluator().getNumberResult("!0"));
assertTrue(0 == getEvaluator().getNumberResult("!1"));
assertEquals(true, getEvaluator().getBooleanResult("!(3+4==6)"));
}
@Test
public void testBooleanNotWithInput() {
assertTrue(1 == getEvaluator().getNumberResult("![pos=1]"));
assertTrue(0 == getEvaluator().getNumberResult("![pos=2]"));
}
@Test
public void testBooleanNotWithVariables() {
assertTrue(1 == getEvaluator().getNumberResult("![var=a]"));
assertTrue(0 == getEvaluator().getNumberResult("![var=b]"));
}
@Test
public void testBooleanNotWithExpressions() {
assertTrue(0 == getEvaluator().getNumberResult("!!0"));
assertTrue(1 == getEvaluator().getNumberResult("!!!0"));
}
@Test(expected=UnsupportedUnaryOperatorException.class)
public void testBooleanNotWithWrongInputCharacter() {
getEvaluator().getNumberResult("!'a'");
}
Hinweise
- Wenn der Boolean b true ist gibt !b false zurück.