GreaterThanOrEqual: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 23: | Zeile 23: | ||
<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 { | |||
greaterThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null)); | |||
greaterThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null)); | |||
greaterThanExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null)); | |||
greaterThanExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null)); | |||
} | |||
@Test | |||
public void testGreaterThan1() { | |||
assertTrue(Evaluator.getBooleanResult("22>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThan2() { | |||
assertTrue(!Evaluator.getBooleanResult("2>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThan3() { | |||
assertTrue(Evaluator.getBooleanResult("5.7>3.5", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThan4() { | |||
assertTrue(Evaluator.getBooleanResult("1>-1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThan5() { | |||
assertTrue(Evaluator.getBooleanResult("0.2>0", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithVariables1() { | |||
assertTrue(Evaluator.getBooleanResult("[var=b]>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithVariables2() { | |||
assertTrue(!Evaluator.getBooleanResult("[var=a]>9", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithVariables3() { | |||
assertTrue(Evaluator.getBooleanResult("[var=b]>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithVariables4() { | |||
assertTrue(!Evaluator.getBooleanResult("[var=a]>[var=b]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithVariables5() { | |||
assertTrue(Evaluator.getBooleanResult("22>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithVariables6() { | |||
assertTrue(!Evaluator.getBooleanResult("2>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithInput1() { | |||
assertTrue(Evaluator.getBooleanResult("[pos=1]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithInput2() { | |||
assertTrue(Evaluator.getBooleanResult("34>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithInput3() { | |||
assertTrue(!Evaluator.getBooleanResult("[pos=2]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithInput4() { | |||
assertTrue(Evaluator.getBooleanResult("[pos=1]>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanWithInput5() { | ||
assertTrue(!Evaluator.getBooleanResult("[pos=2]>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanWithInput6() { | ||
assertTrue(Evaluator.getBooleanResult("22>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanWithInput7() { | ||
assertTrue(!Evaluator.getBooleanResult("2>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanWithEncapsulation1() { | |||
assertTrue(Evaluator.getBooleanResult("1 > (1 > 2)", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanWithEncapsulation2() { | ||
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > 2))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanWithEncapsulation3() { | ||
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > (1 > (1 > 2))))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanWithEncapsulation4() { | ||
assertTrue(Evaluator.getBooleanResult("((((1 > 1) > 1) > 1) > 1) > -1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap)); | |||
} | } | ||
@Test(expected=ParserException.class) | |||
public void testGreaterThanWithWrongInputCharacter() { | |||
Evaluator.getBooleanResult("6 > ab", greaterThanExerciseVariableMap, greaterThanFillInVariableMap); | |||
fail(); | |||
} | |||
@Test(expected=FunctionInvalidArgumentTypeException.class) | |||
public void testGreaterThanWithWrongInputString() { | |||
Evaluator.getBooleanResult("6 > 'a'", greaterThanExerciseVariableMap, greaterThanFillInVariableMap); | |||
fail(); | |||
} | |||
@Test (expected=UndefinedExerciseVariableException.class) | @Test (expected=UndefinedExerciseVariableException.class) | ||
public void | public void testGreaterThanWithMissingExcerciseVariable() { | ||
Evaluator.getBooleanResult("[var=j] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test (expected=UndefinedFillInVariableException.class) | @Test (expected=UndefinedFillInVariableException.class) | ||
public void | public void testGreaterThanWithMissingInput() { | ||
Evaluator.getBooleanResult("[pos=42] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Hinweise=== | ===Hinweise=== | ||
[[Kategorie:Evaluatorfunktion]] | [[Kategorie:Evaluatorfunktion]] |
Version vom 18. September 2017, 11:58 Uhr
Beschreibung
Die Funktion greaterThanOrEqual vergleicht zwei Ausdrücke der Größe nach miteinander und gibt einen Wahrheitswert zurück, abhängig davon, ob der linksstehende Ausdruck größer-gleich dem rechtsstehenden Ausdruck ist.
Syntax
a >= b
Parameter
- a - double
- b - double
Return Value
- Gibt einen Boolean zurück.
- Wenn der linke Ausdruck größer-gleich dem rechten Ausdruck ist, wird
true
zurückgegeben, andernfallsfalse
.
- Wenn der linke Ausdruck größer-gleich dem rechten Ausdruck ist, wird
Beispiele
<math>6 >= 3</math> --> returns true
<math>3 >= 3</math> --> returns true
<math>-1 >= 2</math> --> returns false
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
greaterThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
greaterThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
greaterThanExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
greaterThanExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
}
@Test
public void testGreaterThan1() {
assertTrue(Evaluator.getBooleanResult("22>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThan2() {
assertTrue(!Evaluator.getBooleanResult("2>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThan3() {
assertTrue(Evaluator.getBooleanResult("5.7>3.5", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThan4() {
assertTrue(Evaluator.getBooleanResult("1>-1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThan5() {
assertTrue(Evaluator.getBooleanResult("0.2>0", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithVariables1() {
assertTrue(Evaluator.getBooleanResult("[var=b]>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithVariables2() {
assertTrue(!Evaluator.getBooleanResult("[var=a]>9", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithVariables3() {
assertTrue(Evaluator.getBooleanResult("[var=b]>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithVariables4() {
assertTrue(!Evaluator.getBooleanResult("[var=a]>[var=b]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithVariables5() {
assertTrue(Evaluator.getBooleanResult("22>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithVariables6() {
assertTrue(!Evaluator.getBooleanResult("2>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithInput1() {
assertTrue(Evaluator.getBooleanResult("[pos=1]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithInput2() {
assertTrue(Evaluator.getBooleanResult("34>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithInput3() {
assertTrue(!Evaluator.getBooleanResult("[pos=2]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithInput4() {
assertTrue(Evaluator.getBooleanResult("[pos=1]>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithInput5() {
assertTrue(!Evaluator.getBooleanResult("[pos=2]>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithInput6() {
assertTrue(Evaluator.getBooleanResult("22>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithInput7() {
assertTrue(!Evaluator.getBooleanResult("2>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithEncapsulation1() {
assertTrue(Evaluator.getBooleanResult("1 > (1 > 2)", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithEncapsulation2() {
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > 2))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithEncapsulation3() {
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > (1 > (1 > 2))))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test
public void testGreaterThanWithEncapsulation4() {
assertTrue(Evaluator.getBooleanResult("((((1 > 1) > 1) > 1) > 1) > -1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
@Test(expected=ParserException.class)
public void testGreaterThanWithWrongInputCharacter() {
Evaluator.getBooleanResult("6 > ab", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testGreaterThanWithWrongInputString() {
Evaluator.getBooleanResult("6 > 'a'", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
fail();
}
@Test (expected=UndefinedExerciseVariableException.class)
public void testGreaterThanWithMissingExcerciseVariable() {
Evaluator.getBooleanResult("[var=j] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
fail();
}
@Test (expected=UndefinedFillInVariableException.class)
public void testGreaterThanWithMissingInput() {
Evaluator.getBooleanResult("[pos=42] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
fail();
}