NotEqual: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
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"> | ||
@ | @BeforeClass | ||
public void beforeTest() { | 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 | @Test | ||
public void | public void testNotEqual1() { | ||
assertTrue(Evaluator.getBooleanResult("1 != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testNotEqual2() { | ||
assertTrue(Evaluator.getBooleanResult("30 != 7", notEqualExerciseVariableMap, notEqualFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testNotEqual3() { | ||
assertTrue(Evaluator.getBooleanResult("-10 != 3", notEqualExerciseVariableMap, notEqualFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testNotEqual4() { | ||
assertTrue(!Evaluator.getBooleanResult("1 != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap)); | |||
} | } | ||
@Test(expected= | @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() { | ||
Evaluator.getBooleanResult("1 == ab", notEqualExerciseVariableMap, notEqualFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test (expected=UndefinedExerciseVariableException.class) | @Test (expected=UndefinedExerciseVariableException.class) | ||
public void testNotEqualWithMissingExcerciseVariable() { | public void testNotEqualWithMissingExcerciseVariable() { | ||
Evaluator.getBooleanResult("[var=j] == 2", notEqualExerciseVariableMap, notEqualFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test (expected=UndefinedFillInVariableException.class) | @Test (expected=UndefinedFillInVariableException.class) | ||
public void testNotEqualWithMissingInput() { | public void testNotEqualWithMissingInput() { | ||
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
<math>4!=6</math> --> 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();
}