GreaterThan: 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 { | |||
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(expected= | @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() { | public void testGreaterThanWithWrongInputCharacter() { | ||
Evaluator.getBooleanResult("6 > ab", greaterThanExerciseVariableMap, greaterThanFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected=FunctionInvalidArgumentTypeException.class) | ||
public void testGreaterThanWithWrongInputString() { | public void testGreaterThanWithWrongInputString() { | ||
Evaluator.getBooleanResult("6 > 'a'", greaterThanExerciseVariableMap, greaterThanFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test (expected=UndefinedExerciseVariableException.class) | @Test (expected=UndefinedExerciseVariableException.class) | ||
public void testGreaterThanWithMissingExcerciseVariable() { | public void testGreaterThanWithMissingExcerciseVariable() { | ||
Evaluator.getBooleanResult("[var=j] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test (expected=UndefinedFillInVariableException.class) | @Test (expected=UndefinedFillInVariableException.class) | ||
public void testGreaterThanWithMissingInput() { | public void testGreaterThanWithMissingInput() { | ||
Evaluator.getBooleanResult("[pos=42] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 18. September 2017, 11:54 Uhr
Beschreibung
Die Funktion greaterThan vergleicht zwei Ausdrücke nach der Größe miteinander.
Syntax
a > b
Parameter
- a - double
- b - double
Return Value
- Gibt einen Boolean zurück
Beispiele
<math>6 > 3</math>
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();
}