GreaterThanOrEqual: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Zeile 26: | Zeile 26: | ||
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException, | public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException, | ||
UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException { | UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException { | ||
greaterThanOrEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null)); | |||
greaterThanOrEqualFillInVariableMap.put(2, ExpressionParser.parse("1", null, null)); | |||
greaterThanOrEqualExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null)); | |||
greaterThanOrEqualExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqual1() { | ||
assertTrue(Evaluator.getBooleanResult("22>8", | assertTrue(Evaluator.getBooleanResult("22>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqual2() { | ||
assertTrue( | assertTrue(Evaluator.getBooleanResult("8>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqual3() { | ||
assertTrue(Evaluator.getBooleanResult(" | assertTrue(!Evaluator.getBooleanResult("2>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqual4() { | ||
assertTrue(Evaluator.getBooleanResult(" | assertTrue(Evaluator.getBooleanResult("9>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqual5() { | ||
assertTrue(Evaluator.getBooleanResult(" | assertTrue(!Evaluator.getBooleanResult("7>=45", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqual6() { | ||
assertTrue(Evaluator.getBooleanResult(" | assertTrue(Evaluator.getBooleanResult("7>=7", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqual7() { | ||
assertTrue( | assertTrue(Evaluator.getBooleanResult("0>=-0.2", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqual8() { | ||
assertTrue(Evaluator.getBooleanResult(" | assertTrue(Evaluator.getBooleanResult("0>=0", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithVariables1() { | ||
assertTrue( | assertTrue(Evaluator.getBooleanResult("22>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithVariables2() { | ||
assertTrue(Evaluator.getBooleanResult(" | assertTrue(!Evaluator.getBooleanResult("2>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithVariables3() { | ||
assertTrue( | assertTrue(Evaluator.getBooleanResult("[var=b]>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithVariables4() { | ||
assertTrue(Evaluator.getBooleanResult("[ | assertTrue(Evaluator.getBooleanResult("[var=a]>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithVariables5() { | ||
assertTrue(Evaluator.getBooleanResult(" | assertTrue(!Evaluator.getBooleanResult("23>=[var=b]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithVariables6() { | ||
assertTrue( | assertTrue(Evaluator.getBooleanResult("[var=a]>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithVariables7() { | ||
assertTrue(Evaluator.getBooleanResult("[ | assertTrue(Evaluator.getBooleanResult("[var=b]>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithVariables8() { | ||
assertTrue(!Evaluator.getBooleanResult("[ | assertTrue(!Evaluator.getBooleanResult("[var=a]>=[var=b]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithInput1() { | ||
assertTrue(Evaluator.getBooleanResult("22>[pos=1]", | assertTrue(Evaluator.getBooleanResult("22>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithInput2() { | ||
assertTrue( | assertTrue(Evaluator.getBooleanResult("3>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithInput3() { | ||
assertTrue(Evaluator.getBooleanResult("1 | assertTrue(!Evaluator.getBooleanResult("2>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | |||
@Test | |||
public void testGreaterThanOrEqualWithInput4() { | |||
assertTrue(Evaluator.getBooleanResult("5>=[pos=2]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanOrEqualWithInput5() { | |||
assertTrue(!Evaluator.getBooleanResult("[pos=2]>=5", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithInput6() { | ||
assertTrue(!Evaluator.getBooleanResult(" | assertTrue(!Evaluator.getBooleanResult("[pos=2]>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithEncapsulation1() { | ||
assertTrue( | assertTrue(Evaluator.getBooleanResult("1 >= (1 >= 2)", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | } | ||
@Test | @Test | ||
public void | public void testGreaterThanOrEqualWithEncapsulation2() { | ||
assertTrue(Evaluator.getBooleanResult("((((1 > 1) > 1) > 1) > 1) > | assertFalse(Evaluator.getBooleanResult("0 >= (0 >= (0 >= 1))", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | ||
} | |||
@Test | |||
public void testGreaterThanOrEqualWithEncapsulation3() { | |||
assertFalse(Evaluator.getBooleanResult("0 >= (0 >= (0 >= (0 >= (0 >= 1))))", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testGreaterThanOrEqualWithEncapsulation4() { | |||
assertTrue(Evaluator.getBooleanResult("((((1 >= 1) >= 1) >= 1) >= 1) >= 1", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap)); | |||
} | } | ||
@Test(expected=ParserException.class) | @Test(expected=ParserException.class) | ||
public void | public void testGreaterThanOrEqualWithWrongInputCharacter() { | ||
Evaluator.getBooleanResult("6 > ab", | Evaluator.getBooleanResult("6 >= ab", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap); | ||
fail(); | fail(); | ||
} | } | ||
@Test(expected=FunctionInvalidArgumentTypeException.class) | @Test(expected=FunctionInvalidArgumentTypeException.class) | ||
public void | public void testGreaterThanOrEqualWithWrongInputString() { | ||
Evaluator.getBooleanResult("6 > 'a'", | Evaluator.getBooleanResult("6 >= 'a'", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap); | ||
fail(); | fail(); | ||
} | } | ||
@Test (expected=UndefinedExerciseVariableException.class) | @Test (expected=UndefinedExerciseVariableException.class) | ||
public void | public void testGreaterThanOrEqualWithMissingExcerciseVariable() { | ||
Evaluator.getBooleanResult("[var=j] > 2", | Evaluator.getBooleanResult("[var=j] >= 2", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap); | ||
fail(); | fail(); | ||
} | } | ||
@Test (expected=UndefinedFillInVariableException.class) | @Test (expected=UndefinedFillInVariableException.class) | ||
public void | public void testGreaterThanOrEqualWithMissingInput() { | ||
Evaluator.getBooleanResult("[pos=42] > 2", | Evaluator.getBooleanResult("[pos=42] >= 2", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap); | ||
fail(); | fail(); | ||
} | } |
Version vom 18. September 2017, 11:59 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 {
greaterThanOrEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
greaterThanOrEqualFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
greaterThanOrEqualExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
greaterThanOrEqualExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
}
@Test
public void testGreaterThanOrEqual1() {
assertTrue(Evaluator.getBooleanResult("22>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqual2() {
assertTrue(Evaluator.getBooleanResult("8>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqual3() {
assertTrue(!Evaluator.getBooleanResult("2>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqual4() {
assertTrue(Evaluator.getBooleanResult("9>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqual5() {
assertTrue(!Evaluator.getBooleanResult("7>=45", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqual6() {
assertTrue(Evaluator.getBooleanResult("7>=7", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqual7() {
assertTrue(Evaluator.getBooleanResult("0>=-0.2", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqual8() {
assertTrue(Evaluator.getBooleanResult("0>=0", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithVariables1() {
assertTrue(Evaluator.getBooleanResult("22>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithVariables2() {
assertTrue(!Evaluator.getBooleanResult("2>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithVariables3() {
assertTrue(Evaluator.getBooleanResult("[var=b]>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithVariables4() {
assertTrue(Evaluator.getBooleanResult("[var=a]>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithVariables5() {
assertTrue(!Evaluator.getBooleanResult("23>=[var=b]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithVariables6() {
assertTrue(Evaluator.getBooleanResult("[var=a]>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithVariables7() {
assertTrue(Evaluator.getBooleanResult("[var=b]>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithVariables8() {
assertTrue(!Evaluator.getBooleanResult("[var=a]>=[var=b]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithInput1() {
assertTrue(Evaluator.getBooleanResult("22>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithInput2() {
assertTrue(Evaluator.getBooleanResult("3>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithInput3() {
assertTrue(!Evaluator.getBooleanResult("2>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithInput4() {
assertTrue(Evaluator.getBooleanResult("5>=[pos=2]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithInput5() {
assertTrue(!Evaluator.getBooleanResult("[pos=2]>=5", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithInput6() {
assertTrue(!Evaluator.getBooleanResult("[pos=2]>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithEncapsulation1() {
assertTrue(Evaluator.getBooleanResult("1 >= (1 >= 2)", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithEncapsulation2() {
assertFalse(Evaluator.getBooleanResult("0 >= (0 >= (0 >= 1))", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithEncapsulation3() {
assertFalse(Evaluator.getBooleanResult("0 >= (0 >= (0 >= (0 >= (0 >= 1))))", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test
public void testGreaterThanOrEqualWithEncapsulation4() {
assertTrue(Evaluator.getBooleanResult("((((1 >= 1) >= 1) >= 1) >= 1) >= 1", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
}
@Test(expected=ParserException.class)
public void testGreaterThanOrEqualWithWrongInputCharacter() {
Evaluator.getBooleanResult("6 >= ab", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testGreaterThanOrEqualWithWrongInputString() {
Evaluator.getBooleanResult("6 >= 'a'", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap);
fail();
}
@Test (expected=UndefinedExerciseVariableException.class)
public void testGreaterThanOrEqualWithMissingExcerciseVariable() {
Evaluator.getBooleanResult("[var=j] >= 2", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap);
fail();
}
@Test (expected=UndefinedFillInVariableException.class)
public void testGreaterThanOrEqualWithMissingInput() {
Evaluator.getBooleanResult("[pos=42] >= 2", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap);
fail();
}