BooleanNot: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 20: | Zeile 20: | ||
<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"> | ||
@ | @Test | ||
public void | 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 | @Test | ||
public void | public void testBooleanNotWithVariables1() { | ||
assertEquals(1, Evaluator.getNumberResult("![var=a]", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testBooleanNotWithVariables2() { | ||
assertEquals(0, Evaluator.getNumberResult("![var=b]", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testBooleanNotWithExpressions1() { | ||
assertEquals(0, Evaluator.getNumberResult("!!0", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testBooleanNotWithExpressions2() { | ||
assertEquals(1, Evaluator.getNumberResult("!!!0", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test(expected= | @Test(expected=FunctionInvalidArgumentTypeException.class) | ||
public void testBooleanNotWithWrongInputCharacter() { | public void testBooleanNotWithWrongInputCharacter() { | ||
Evaluator.getNumberResult("!'a'", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 18. September 2017, 10:35 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.