GreaterThan: Unterschied zwischen den Versionen

Aus JACK Wiki
Wechseln zu: Navigation, Suche
(JUnit Tests)
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">
@Before
+
@BeforeClass
public void beforeTest() {
+
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
  placeFillInVariable(1, OMParser.parse("3"));
+
UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
  placeFillInVariable(2, OMParser.parse("1"));
+
greaterThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
+
greaterThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
  placeExerciseVariable("a", OMParser.parse("8"));
+
 
  placeExerciseVariable("b", OMParser.parse("25"));
+
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 testGreaterThan(){
+
public void testGreaterThanWithInput5() {
  assertTrue(getEvaluator().getBooleanResult("22>8"));
+
assertTrue(!Evaluator.getBooleanResult("[pos=2]>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(!getEvaluator().getBooleanResult("2>8"));
 
  assertTrue(getEvaluator().getBooleanResult("5.7>3.5"));
 
  assertTrue(getEvaluator().getBooleanResult("1>-1"));
 
  assertTrue(getEvaluator().getBooleanResult("0.2>0"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testGreaterThanWithVariables() {
+
public void testGreaterThanWithInput6() {
  assertTrue(getEvaluator().getBooleanResult("[var=b]>8"));
+
assertTrue(Evaluator.getBooleanResult("22>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(!getEvaluator().getBooleanResult("[var=a]>9"));
 
  assertTrue(getEvaluator().getBooleanResult("[var=b]>[var=a]"));
 
  assertTrue(!getEvaluator().getBooleanResult("[var=a]>[var=b]"));
 
  assertTrue(getEvaluator().getBooleanResult("22>[var=a]"));
 
  assertTrue(!getEvaluator().getBooleanResult("2>[var=a]"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testGreaterThanWithInput() {
+
public void testGreaterThanWithInput7() {
  assertTrue(getEvaluator().getBooleanResult("[pos=1]>2"));
+
assertTrue(!Evaluator.getBooleanResult("2>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("34>[pos=2]"));
+
}
  assertTrue(!getEvaluator().getBooleanResult("[pos=2]>2"));
+
 
  assertTrue(getEvaluator().getBooleanResult("[pos=1]>[pos=2]"));
+
@Test
  assertTrue(!getEvaluator().getBooleanResult("[pos=2]>[pos=1]"));
+
public void testGreaterThanWithEncapsulation1() {
  assertTrue(getEvaluator().getBooleanResult("22>[pos=1]"));
+
assertTrue(Evaluator.getBooleanResult("1 > (1 > 2)", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(!getEvaluator().getBooleanResult("2>[pos=1]"));
 
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithEncapsulation(){
+
public void testGreaterThanWithEncapsulation2() {
  assertTrue(getEvaluator().getBooleanResult("1 > (1 > 2)"));
+
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > 2))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(!getEvaluator().getBooleanResult("1 > (1 > (1 > 2))"));
 
  assertTrue(!getEvaluator().getBooleanResult("1 > (1 > (1 > (1 > (1 > 2))))"));
 
  assertTrue(getEvaluator().getBooleanResult("((((1 > 1) > 1) > 1) > 1) > -1"));
 
 
}
 
}
+
 
@Test(expected=ParserMismatchException.class)
+
@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() {
  getEvaluator().getBooleanResult("6 > a");
+
Evaluator.getBooleanResult("6 > ab", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
 +
fail();
 
}
 
}
+
 
@Test(expected=UnsupportedBinaryOperatorException.class)
+
@Test(expected=FunctionInvalidArgumentTypeException.class)
 
public void testGreaterThanWithWrongInputString() {
 
public void testGreaterThanWithWrongInputString() {
  getEvaluator().getBooleanResult("6 > 'a'");
+
Evaluator.getBooleanResult("6 > 'a'", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
 +
fail();
 
}
 
}
+
 
 
@Test (expected=UndefinedExerciseVariableException.class)
 
@Test (expected=UndefinedExerciseVariableException.class)
 
public void testGreaterThanWithMissingExcerciseVariable() {
 
public void testGreaterThanWithMissingExcerciseVariable() {
  getEvaluator().getBooleanResult("[var=j] > 2");
+
Evaluator.getBooleanResult("[var=j] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
 +
fail();
 
}
 
}
+
 
 
@Test (expected=UndefinedFillInVariableException.class)
 
@Test (expected=UndefinedFillInVariableException.class)
 
public void testGreaterThanWithMissingInput() {
 
public void testGreaterThanWithMissingInput() {
  getEvaluator().getBooleanResult("[pos=42] > 2");
+
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


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();
}

Hinweise