GreaterThanOrEqual

Aus JACK Wiki
Zur Navigation springen Zur Suche springen

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
greaterThanOrEqual(a,b)

Parameter

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

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

Hinweise