LessThanOrEqual: 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 { | |||
lessThanOrEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null)); | |||
lessThanOrEqualFillInVariableMap.put(2, ExpressionParser.parse("1", null, null)); | |||
lessThanOrEqualFillInVariableMap.put(3, ExpressionParser.parse("2.5", null, null)); | |||
lessThanOrEqualExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null)); | |||
lessThanOrEqualExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null)); | |||
lessThanOrEqualExerciseVariableMap.put("c", ExpressionParser.parse("2.5", null, null)); | |||
} | |||
@Test | |||
public void testLessThanOrEqual1() { | |||
assertTrue(!Evaluator.getBooleanResult("22<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqual2() { | |||
assertTrue(Evaluator.getBooleanResult("8<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqual3() { | |||
assertTrue(Evaluator.getBooleanResult("2<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqual4() { | |||
assertTrue(Evaluator.getBooleanResult("8<=9", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqual5() { | |||
assertTrue(!Evaluator.getBooleanResult("45<=7", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqual6() { | |||
assertTrue(Evaluator.getBooleanResult("7<=7", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqual7() { | |||
assertTrue(Evaluator.getBooleanResult("-0.2<=0", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqual8() { | |||
assertTrue(Evaluator.getBooleanResult("0<=0", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithVariables1() { | |||
assertTrue(!Evaluator.getBooleanResult("22<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithVariables2() { | |||
assertTrue(Evaluator.getBooleanResult("3<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithVariables3() { | |||
assertTrue(Evaluator.getBooleanResult("2<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithVariables4() { | |||
assertTrue(Evaluator.getBooleanResult("8<=[var=b]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testLessThanOrEqualWithVariables5() { | ||
assertTrue(Evaluator.getBooleanResult("8<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | } | ||
@Test | |||
public void testLessThanOrEqualWithVariables6() { | |||
assertTrue(!Evaluator.getBooleanResult("[var=b]<=23", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithVariables7() { | |||
assertTrue(Evaluator.getBooleanResult("[var=a]<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithVariables8() { | |||
assertTrue(Evaluator.getBooleanResult("[var=a]<=[var=b]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithVariables9() { | |||
assertTrue(!Evaluator.getBooleanResult("[var=b]<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithInput1() { | |||
assertTrue(!Evaluator.getBooleanResult("22<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithInput2() { | |||
assertTrue(Evaluator.getBooleanResult("3<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithInput3() { | |||
assertTrue(Evaluator.getBooleanResult("2<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithInput4() { | |||
assertTrue(Evaluator.getBooleanResult("3<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithInput5() { | |||
assertTrue(Evaluator.getBooleanResult("[pos=2]<=5", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithInput6() { | |||
assertTrue(!Evaluator.getBooleanResult("5<=[pos=2]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithInput7() { | |||
assertTrue(!Evaluator.getBooleanResult("[pos=1]<=[pos=2]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | |||
public void testLessThanOrEqualWithEncapsulation1() { | |||
assertTrue(Evaluator.getBooleanResult("1 <= (1 <= 2)", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | |||
@Test | @Test | ||
public void | public void testLessThanOrEqualWithEncapsulation2() { | ||
assertTrue(Evaluator.getBooleanResult("1 <= (1 <= (0 <= 1))", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testLessThanOrEqualWithEncapsulation3() { | ||
assertTrue(Evaluator.getBooleanResult("0 <= (0 <= (0 <= (0 <= (0 <= 1))))", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testLessThanOrEqualWithEncapsulation4() { | ||
assertTrue(Evaluator.getBooleanResult("((((1 <= 1) <= 1) <= 1) <= 1) <= 1", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap)); | |||
} | } | ||
@Test(expected= | @Test(expected=ParserException.class) | ||
public void testLessThanOrEqualWithWrongInputCharacter() { | public void testLessThanOrEqualWithWrongInputCharacter() { | ||
Evaluator.getBooleanResult("6 <= ab", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected=FunctionInvalidArgumentTypeException.class) | ||
public void testLessThanOrEqualWithWrongInputString() { | public void testLessThanOrEqualWithWrongInputString() { | ||
Evaluator.getBooleanResult("6 <= 'a'", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test (expected=UndefinedExerciseVariableException.class) | @Test (expected=UndefinedExerciseVariableException.class) | ||
public void testLessThanOrEqualWithMissingExcerciseVariable() { | public void testLessThanOrEqualWithMissingExcerciseVariable() { | ||
Evaluator.getBooleanResult("[var=j] <= 2", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test (expected=UndefinedFillInVariableException.class) | @Test (expected=UndefinedFillInVariableException.class) | ||
public void testLessThanOrEqualWithMissingInput() { | public void testLessThanOrEqualWithMissingInput() { | ||
Evaluator.getBooleanResult("[pos=42] <= 2", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 19. September 2017, 07:31 Uhr
Beschreibung
Die Funktion lessThanOrEqual vergleicht zwei Ausdrücke der Größe nach miteinander und gibt einen Wahrheitswert zurück, abhängig davon, ob der linksstehende Ausdruck kleiner-gleich dem rechtsstehenden Ausdruck ist.
Syntax
a <= b
Parameter
- a - double
- b - double
Return Value
- Gibt einen Boolean zurück.
- Wenn der linke Ausdruck kleiner-gleich dem rechten Ausdruck ist, wird
true
zurückgegeben, andernfallsfalse
.
- Wenn der linke Ausdruck kleiner-gleich dem rechten Ausdruck ist, wird
Beispiele
<math>2 <= 4</math> --> returns true
<math>4 <= 4</math> --> returns true
<math>3 <= 2</math> --> returns false
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
lessThanOrEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
lessThanOrEqualFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
lessThanOrEqualFillInVariableMap.put(3, ExpressionParser.parse("2.5", null, null));
lessThanOrEqualExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
lessThanOrEqualExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
lessThanOrEqualExerciseVariableMap.put("c", ExpressionParser.parse("2.5", null, null));
}
@Test
public void testLessThanOrEqual1() {
assertTrue(!Evaluator.getBooleanResult("22<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqual2() {
assertTrue(Evaluator.getBooleanResult("8<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqual3() {
assertTrue(Evaluator.getBooleanResult("2<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqual4() {
assertTrue(Evaluator.getBooleanResult("8<=9", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqual5() {
assertTrue(!Evaluator.getBooleanResult("45<=7", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqual6() {
assertTrue(Evaluator.getBooleanResult("7<=7", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqual7() {
assertTrue(Evaluator.getBooleanResult("-0.2<=0", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqual8() {
assertTrue(Evaluator.getBooleanResult("0<=0", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables1() {
assertTrue(!Evaluator.getBooleanResult("22<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables2() {
assertTrue(Evaluator.getBooleanResult("3<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables3() {
assertTrue(Evaluator.getBooleanResult("2<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables4() {
assertTrue(Evaluator.getBooleanResult("8<=[var=b]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables5() {
assertTrue(Evaluator.getBooleanResult("8<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables6() {
assertTrue(!Evaluator.getBooleanResult("[var=b]<=23", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables7() {
assertTrue(Evaluator.getBooleanResult("[var=a]<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables8() {
assertTrue(Evaluator.getBooleanResult("[var=a]<=[var=b]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithVariables9() {
assertTrue(!Evaluator.getBooleanResult("[var=b]<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithInput1() {
assertTrue(!Evaluator.getBooleanResult("22<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithInput2() {
assertTrue(Evaluator.getBooleanResult("3<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithInput3() {
assertTrue(Evaluator.getBooleanResult("2<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithInput4() {
assertTrue(Evaluator.getBooleanResult("3<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithInput5() {
assertTrue(Evaluator.getBooleanResult("[pos=2]<=5", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithInput6() {
assertTrue(!Evaluator.getBooleanResult("5<=[pos=2]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithInput7() {
assertTrue(!Evaluator.getBooleanResult("[pos=1]<=[pos=2]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithEncapsulation1() {
assertTrue(Evaluator.getBooleanResult("1 <= (1 <= 2)", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithEncapsulation2() {
assertTrue(Evaluator.getBooleanResult("1 <= (1 <= (0 <= 1))", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithEncapsulation3() {
assertTrue(Evaluator.getBooleanResult("0 <= (0 <= (0 <= (0 <= (0 <= 1))))", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test
public void testLessThanOrEqualWithEncapsulation4() {
assertTrue(Evaluator.getBooleanResult("((((1 <= 1) <= 1) <= 1) <= 1) <= 1", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
@Test(expected=ParserException.class)
public void testLessThanOrEqualWithWrongInputCharacter() {
Evaluator.getBooleanResult("6 <= ab", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testLessThanOrEqualWithWrongInputString() {
Evaluator.getBooleanResult("6 <= 'a'", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
fail();
}
@Test (expected=UndefinedExerciseVariableException.class)
public void testLessThanOrEqualWithMissingExcerciseVariable() {
Evaluator.getBooleanResult("[var=j] <= 2", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
fail();
}
@Test (expected=UndefinedFillInVariableException.class)
public void testLessThanOrEqualWithMissingInput() {
Evaluator.getBooleanResult("[pos=42] <= 2", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
fail();
}