NotEqual: Unterschied zwischen den Versionen

Aus JACK Wiki
Wechseln zu: Navigation, Suche
(JUnit Tests)
Zeile 18: Zeile 18:
 
<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
+
@BeforeClass
public void beforeTest() {
+
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
  placeFillInVariable(1, OMParser.parse("3"));
+
UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
  placeFillInVariable(2, OMParser.parse("10"));
+
notEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
  placeFillInVariable(3, OMParser.parse("3.5"));
+
notEqualFillInVariableMap.put(2, ExpressionParser.parse("10", null, null));
 +
notEqualFillInVariableMap.put(3, ExpressionParser.parse("3.5", null, null));
  
  placeExerciseVariable("a", OMParser.parse("3"));
+
notEqualExerciseVariableMap.put("a", ExpressionParser.parse("3", null, null));
  placeExerciseVariable("b", OMParser.parse("10"));
+
notEqualExerciseVariableMap.put("b", ExpressionParser.parse("10", null, null));
  placeExerciseVariable("c", OMParser.parse("3.5"));
+
notEqualExerciseVariableMap.put("c", ExpressionParser.parse("3.5", null, null));
 
}
 
}
+
 
 
@Test
 
@Test
public void testNotEqual(){
+
public void testNotEqual1() {
  assertTrue(getEvaluator().getBooleanResult("1 != 0"));
+
assertTrue(Evaluator.getBooleanResult("1 != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("30 != 7"));
 
  assertTrue(getEvaluator().getBooleanResult("-10 != 3"));
 
  assertTrue(!getEvaluator().getBooleanResult("1 != 1"));
 
  assertTrue(!getEvaluator().getBooleanResult("0 != 0"));
 
 
  assertTrue(getEvaluator().getBooleanResult("'a' != 'b'"));
 
  assertTrue(getEvaluator().getBooleanResult("'' != 0"));
 
  assertTrue(getEvaluator().getBooleanResult("0 != ''"));
 
  assertTrue(!getEvaluator().getBooleanResult("0 != '0'"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testNotEqualWithVariables(){
+
public void testNotEqual2() {
  assertTrue(getEvaluator().getBooleanResult("[var=a] != 0"));
+
assertTrue(Evaluator.getBooleanResult("30 != 7", notEqualExerciseVariableMap, notEqualFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("30 != [var=a]"));
 
  assertTrue(getEvaluator().getBooleanResult("[var=a]!= [var=b]"));
 
  assertTrue(!getEvaluator().getBooleanResult("[var=a] != [var=a]"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testNotEqualWithInput(){
+
public void testNotEqual3() {
  assertTrue(getEvaluator().getBooleanResult("[pos=1] != 0"));
+
assertTrue(Evaluator.getBooleanResult("-10 != 3", notEqualExerciseVariableMap, notEqualFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("30 != [pos=1]"));
 
  assertTrue(getEvaluator().getBooleanResult("[pos=1] != [pos=2]"));
 
  assertTrue(!getEvaluator().getBooleanResult("[pos=1] != [pos=1]"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testNotEqualWithEncapsulation(){
+
public void testNotEqual4() {
  assertTrue(!getEvaluator().getBooleanResult("1 != (1 != 0)"));
+
assertTrue(!Evaluator.getBooleanResult("1 != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("1 != (1 != (1 != 0))"));
 
  assertTrue(getEvaluator().getBooleanResult("1 != (1 != (1 != (1 != (1 != 0))))"));
 
  assertTrue(!getEvaluator().getBooleanResult("1 != (1 != (1 != (1 != (1 != 1))))"));
 
  assertTrue(getEvaluator().getBooleanResult("((((1 != 0) != 1) != 1) != 1) != 1"));
 
  assertTrue(!getEvaluator().getBooleanResult("((((1 != 1) != 1) != 1) != 1) != 1"));
 
 
}
 
}
+
 
@Test(expected=ParserMismatchException.class)
+
@Test
 +
public void testNotEqual5() {
 +
assertTrue(!Evaluator.getBooleanResult("0 != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqual6() {
 +
assertTrue(Evaluator.getBooleanResult("'a' != 'b'", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqual7() {
 +
assertTrue(Evaluator.getBooleanResult("'' != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqual8() {
 +
assertTrue(Evaluator.getBooleanResult("0 != ''", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqual9() {
 +
assertTrue(!Evaluator.getBooleanResult("0 != '0'", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithVariables1() {
 +
assertTrue(Evaluator.getBooleanResult("[var=a] != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithVariables2() {
 +
assertTrue(Evaluator.getBooleanResult("30 != [var=a]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithVariables3() {
 +
assertTrue(Evaluator.getBooleanResult("[var=a]!= [var=b]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithVariables4() {
 +
assertTrue(!Evaluator.getBooleanResult("[var=a] != [var=a]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithInput1() {
 +
assertTrue(Evaluator.getBooleanResult("[pos=1] != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithInput2() {
 +
assertTrue(Evaluator.getBooleanResult("30 != [pos=1]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithInput3() {
 +
assertTrue(Evaluator.getBooleanResult("[pos=1] != [pos=2]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithInput4() {
 +
assertTrue(!Evaluator.getBooleanResult("[pos=1] != [pos=1]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithEncapsulation1() {
 +
assertFalse(Evaluator.getBooleanResult("1 != (1 != 0)", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithEncapsulation2() {
 +
assertTrue(Evaluator.getBooleanResult("1 != (1 != (1 != 0))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithEncapsulation3() {
 +
assertTrue(Evaluator.getBooleanResult("1 != (1 != (1 != (1 != (1 != 0))))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithEncapsulation4() {
 +
assertFalse(Evaluator.getBooleanResult("1 != (1 != (1 != (1 != (1 != 1))))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithEncapsulation5() {
 +
assertTrue(Evaluator.getBooleanResult("((((1 != 0) != 1) != 1) != 1) != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testNotEqualWithEncapsulation6() {
 +
assertFalse(Evaluator.getBooleanResult("((((1 != 1) != 1) != 1) != 1) != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
 +
}
 +
 
 +
@Test(expected=ParserException.class)
 
public void testNotEqualWithWrongInputCharacter() {
 
public void testNotEqualWithWrongInputCharacter() {
  getEvaluator().getBooleanResult("1 == a");
+
Evaluator.getBooleanResult("1 == ab", notEqualExerciseVariableMap, notEqualFillInVariableMap);
 +
fail();
 
}
 
}
+
 
 
@Test (expected=UndefinedExerciseVariableException.class)
 
@Test (expected=UndefinedExerciseVariableException.class)
 
public void testNotEqualWithMissingExcerciseVariable() {
 
public void testNotEqualWithMissingExcerciseVariable() {
  getEvaluator().getBooleanResult("[var=j] == 2");
+
Evaluator.getBooleanResult("[var=j] == 2", notEqualExerciseVariableMap, notEqualFillInVariableMap);
 +
fail();
 
}
 
}
+
 
 
@Test (expected=UndefinedFillInVariableException.class)
 
@Test (expected=UndefinedFillInVariableException.class)
 
public void testNotEqualWithMissingInput() {
 
public void testNotEqualWithMissingInput() {
  getEvaluator().getBooleanResult("[pos=42] == 2");
+
Evaluator.getBooleanResult("[pos=42] == 2", notEqualExerciseVariableMap, notEqualFillInVariableMap);
 +
fail();
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
===Hinweise===
 
===Hinweise===
  
 
[[Kategorie:Evaluatorfunktion]]
 
[[Kategorie:Evaluatorfunktion]]

Version vom 19. September 2017, 07:36 Uhr

Beschreibung

Die Funktionen notEqual vergleicht zwei Ausdrücke auf Gleichheit miteinander. Wenn die beiden Ausdrücke nicht übereinstimmen gibt die Funktion true zurück, ansonsten false.

Syntax

a != b

Parameter

  • a - double
  • b - double

Return Value

  • Gibt einen Boolean zurück.

Beispiele

    --> returns true

JUnit Tests

[Anzeigen]

@BeforeClass
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
		UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
	notEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
	notEqualFillInVariableMap.put(2, ExpressionParser.parse("10", null, null));
	notEqualFillInVariableMap.put(3, ExpressionParser.parse("3.5", null, null));

	notEqualExerciseVariableMap.put("a", ExpressionParser.parse("3", null, null));
	notEqualExerciseVariableMap.put("b", ExpressionParser.parse("10", null, null));
	notEqualExerciseVariableMap.put("c", ExpressionParser.parse("3.5", null, null));
}

@Test
public void testNotEqual1() {
	assertTrue(Evaluator.getBooleanResult("1 != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual2() {
	assertTrue(Evaluator.getBooleanResult("30 != 7", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual3() {
	assertTrue(Evaluator.getBooleanResult("-10 != 3", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual4() {
	assertTrue(!Evaluator.getBooleanResult("1 != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual5() {
	assertTrue(!Evaluator.getBooleanResult("0 != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual6() {
	assertTrue(Evaluator.getBooleanResult("'a' != 'b'", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual7() {
	assertTrue(Evaluator.getBooleanResult("'' != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual8() {
	assertTrue(Evaluator.getBooleanResult("0 != ''", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual9() {
	assertTrue(!Evaluator.getBooleanResult("0 != '0'", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithVariables1() {
	assertTrue(Evaluator.getBooleanResult("[var=a] != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithVariables2() {
	assertTrue(Evaluator.getBooleanResult("30 != [var=a]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithVariables3() {
	assertTrue(Evaluator.getBooleanResult("[var=a]!= [var=b]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithVariables4() {
	assertTrue(!Evaluator.getBooleanResult("[var=a] != [var=a]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithInput1() {
	assertTrue(Evaluator.getBooleanResult("[pos=1] != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithInput2() {
	assertTrue(Evaluator.getBooleanResult("30 != [pos=1]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithInput3() {
	assertTrue(Evaluator.getBooleanResult("[pos=1] != [pos=2]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithInput4() {
	assertTrue(!Evaluator.getBooleanResult("[pos=1] != [pos=1]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation1() {
	assertFalse(Evaluator.getBooleanResult("1 != (1 != 0)", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation2() {
	assertTrue(Evaluator.getBooleanResult("1 != (1 != (1 != 0))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation3() {
	assertTrue(Evaluator.getBooleanResult("1 != (1 != (1 != (1 != (1 != 0))))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation4() {
	assertFalse(Evaluator.getBooleanResult("1 != (1 != (1 != (1 != (1 != 1))))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation5() {
	assertTrue(Evaluator.getBooleanResult("((((1 != 0) != 1) != 1) != 1) != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation6() {
	assertFalse(Evaluator.getBooleanResult("((((1 != 1) != 1) != 1) != 1) != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test(expected=ParserException.class)
public void testNotEqualWithWrongInputCharacter() {
	Evaluator.getBooleanResult("1 == ab", notEqualExerciseVariableMap, notEqualFillInVariableMap);
	fail();
}

@Test (expected=UndefinedExerciseVariableException.class)
public void testNotEqualWithMissingExcerciseVariable() {
	Evaluator.getBooleanResult("[var=j] == 2", notEqualExerciseVariableMap, notEqualFillInVariableMap);
	fail();
}

@Test (expected=UndefinedFillInVariableException.class)
public void testNotEqualWithMissingInput() {
	Evaluator.getBooleanResult("[pos=42] == 2", notEqualExerciseVariableMap, notEqualFillInVariableMap);
	fail();
}

Hinweise