GreaterThanOrEqual: Unterschied zwischen den Versionen

Aus JACK Wiki
Wechseln zu: Navigation, Suche
(JUnit Tests)
(JUnit Tests)
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 {
greaterThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
+
greaterThanOrEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
greaterThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
+
greaterThanOrEqualFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
  
greaterThanExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
+
greaterThanOrEqualExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
greaterThanExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
+
greaterThanOrEqualExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThan1() {
+
public void testGreaterThanOrEqual1() {
assertTrue(Evaluator.getBooleanResult("22>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("22>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThan2() {
+
public void testGreaterThanOrEqual2() {
assertTrue(!Evaluator.getBooleanResult("2>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("8>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThan3() {
+
public void testGreaterThanOrEqual3() {
assertTrue(Evaluator.getBooleanResult("5.7>3.5", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(!Evaluator.getBooleanResult("2>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThan4() {
+
public void testGreaterThanOrEqual4() {
assertTrue(Evaluator.getBooleanResult("1>-1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("9>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThan5() {
+
public void testGreaterThanOrEqual5() {
assertTrue(Evaluator.getBooleanResult("0.2>0", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(!Evaluator.getBooleanResult("7>=45", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithVariables1() {
+
public void testGreaterThanOrEqual6() {
assertTrue(Evaluator.getBooleanResult("[var=b]>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("7>=7", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithVariables2() {
+
public void testGreaterThanOrEqual7() {
assertTrue(!Evaluator.getBooleanResult("[var=a]>9", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("0>=-0.2", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithVariables3() {
+
public void testGreaterThanOrEqual8() {
assertTrue(Evaluator.getBooleanResult("[var=b]>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("0>=0", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithVariables4() {
+
public void testGreaterThanOrEqualWithVariables1() {
assertTrue(!Evaluator.getBooleanResult("[var=a]>[var=b]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("22>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithVariables5() {
+
public void testGreaterThanOrEqualWithVariables2() {
assertTrue(Evaluator.getBooleanResult("22>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(!Evaluator.getBooleanResult("2>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithVariables6() {
+
public void testGreaterThanOrEqualWithVariables3() {
assertTrue(!Evaluator.getBooleanResult("2>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("[var=b]>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithInput1() {
+
public void testGreaterThanOrEqualWithVariables4() {
assertTrue(Evaluator.getBooleanResult("[pos=1]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("[var=a]>=8", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithInput2() {
+
public void testGreaterThanOrEqualWithVariables5() {
assertTrue(Evaluator.getBooleanResult("34>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(!Evaluator.getBooleanResult("23>=[var=b]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithInput3() {
+
public void testGreaterThanOrEqualWithVariables6() {
assertTrue(!Evaluator.getBooleanResult("[pos=2]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("[var=a]>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithInput4() {
+
public void testGreaterThanOrEqualWithVariables7() {
assertTrue(Evaluator.getBooleanResult("[pos=1]>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("[var=b]>=[var=a]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithInput5() {
+
public void testGreaterThanOrEqualWithVariables8() {
assertTrue(!Evaluator.getBooleanResult("[pos=2]>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(!Evaluator.getBooleanResult("[var=a]>=[var=b]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithInput6() {
+
public void testGreaterThanOrEqualWithInput1() {
assertTrue(Evaluator.getBooleanResult("22>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("22>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithInput7() {
+
public void testGreaterThanOrEqualWithInput2() {
assertTrue(!Evaluator.getBooleanResult("2>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("3>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
@Test  
+
@Test
public void testGreaterThanWithEncapsulation1() {
+
public void testGreaterThanOrEqualWithInput3() {
assertTrue(Evaluator.getBooleanResult("1 > (1 > 2)", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
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 testGreaterThanWithEncapsulation2() {
+
public void testGreaterThanOrEqualWithInput6() {
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > 2))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(!Evaluator.getBooleanResult("[pos=2]>=[pos=1]", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test
 
@Test
public void testGreaterThanWithEncapsulation3() {
+
public void testGreaterThanOrEqualWithEncapsulation1() {
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > (1 > (1 > 2))))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
assertTrue(Evaluator.getBooleanResult("1 >= (1 >= 2)", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap));
 
}
 
}
  
 
@Test  
 
@Test  
public void testGreaterThanWithEncapsulation4() {
+
public void testGreaterThanOrEqualWithEncapsulation2() {
assertTrue(Evaluator.getBooleanResult("((((1 > 1) > 1) > 1) > 1) > -1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
+
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 testGreaterThanWithWrongInputCharacter() {
+
public void testGreaterThanOrEqualWithWrongInputCharacter() {
Evaluator.getBooleanResult("6 > ab", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
+
Evaluator.getBooleanResult("6 >= ab", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap);
 
fail();
 
fail();
 
}
 
}
  
 
@Test(expected=FunctionInvalidArgumentTypeException.class)
 
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testGreaterThanWithWrongInputString() {
+
public void testGreaterThanOrEqualWithWrongInputString() {
Evaluator.getBooleanResult("6 > 'a'", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
+
Evaluator.getBooleanResult("6 >= 'a'", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap);
 
fail();
 
fail();
 
}
 
}
  
 
@Test (expected=UndefinedExerciseVariableException.class)
 
@Test (expected=UndefinedExerciseVariableException.class)
public void testGreaterThanWithMissingExcerciseVariable() {
+
public void testGreaterThanOrEqualWithMissingExcerciseVariable() {
Evaluator.getBooleanResult("[var=j] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
+
Evaluator.getBooleanResult("[var=j] >= 2", greaterThanOrEqualExerciseVariableMap, greaterThanOrEqualFillInVariableMap);
 
fail();
 
fail();
 
}
 
}
  
 
@Test (expected=UndefinedFillInVariableException.class)
 
@Test (expected=UndefinedFillInVariableException.class)
public void testGreaterThanWithMissingInput() {
+
public void testGreaterThanOrEqualWithMissingInput() {
Evaluator.getBooleanResult("[pos=42] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
+
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, andernfalls false.

Beispiele

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

Hinweise