BooleanNot: Unterschied zwischen den Versionen

Aus JACK Wiki
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">
@Before
@Test
public void beforeTest() {
public void testBooleanNot1() {
  placeFillInVariable(1, OMParser.parse("0"));
assertEquals(1, Evaluator.getNumberResult("!0", exerciseVariableMap, fillInVariableMap), 0.0);
  placeFillInVariable(2, OMParser.parse("1"));
}
 
  placeExerciseVariable("a", OMParser.parse("0"));
@Test
  placeExerciseVariable("b", OMParser.parse("1"));
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 testBooleanNot() {
public void testBooleanNotWithVariables1() {
  assertTrue(1 == getEvaluator().getNumberResult("!0"));
assertEquals(1, Evaluator.getNumberResult("![var=a]", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(0 == getEvaluator().getNumberResult("!1"));
  assertEquals(true, getEvaluator().getBooleanResult("!(3+4==6)"));
}
}
 
@Test
@Test
public void testBooleanNotWithInput() {
public void testBooleanNotWithVariables2() {
  assertTrue(1 == getEvaluator().getNumberResult("![pos=1]"));
assertEquals(0, Evaluator.getNumberResult("![var=b]", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(0 == getEvaluator().getNumberResult("![pos=2]"));
}
}
 
@Test
@Test
public void testBooleanNotWithVariables() {
public void testBooleanNotWithExpressions1() {
  assertTrue(1 == getEvaluator().getNumberResult("![var=a]"));
assertEquals(0, Evaluator.getNumberResult("!!0", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(0 == getEvaluator().getNumberResult("![var=b]"));
}
}
 
@Test
@Test
public void testBooleanNotWithExpressions() {
public void testBooleanNotWithExpressions2() {
  assertTrue(0 == getEvaluator().getNumberResult("!!0"));
assertEquals(1, Evaluator.getNumberResult("!!!0", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(1 == getEvaluator().getNumberResult("!!!0"));
}
}
 
@Test(expected=UnsupportedUnaryOperatorException.class)
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testBooleanNotWithWrongInputCharacter() {
public void testBooleanNotWithWrongInputCharacter() {
  getEvaluator().getNumberResult("!'a'");
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.