LessThan: 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"));
+
lessThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
+
lessThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
  placeExerciseVariable("a", OMParser.parse("8"));
+
 
  placeExerciseVariable("b", OMParser.parse("25"));
+
lessThanExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
 +
lessThanExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
 
}
 
}
+
 
 
@Test
 
@Test
public void testLessThan(){
+
public void testLessThan1() {
  assertTrue(getEvaluator().getBooleanResult("8<22"));
+
assertTrue(Evaluator.getBooleanResult("8<22", lessThanExerciseVariableMap, lessThanFillInVariableMap));
  assertTrue(!getEvaluator().getBooleanResult("22<8"));
 
  assertTrue(getEvaluator().getBooleanResult("3.5<5.7"));
 
  assertTrue(getEvaluator().getBooleanResult("-1<1"));
 
  assertTrue(getEvaluator().getBooleanResult("-0.2<0"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testLessThanWithExerciseVariables() {
+
public void testLessThan2() {
  assertTrue(getEvaluator().getBooleanResult("8<[var=b]"));
+
assertTrue(!Evaluator.getBooleanResult("22<8", lessThanExerciseVariableMap, lessThanFillInVariableMap));
  assertTrue(!getEvaluator().getBooleanResult("9<[var=a]"));
 
  assertTrue(!getEvaluator().getBooleanResult("22<[var=a]"));
 
  assertTrue(getEvaluator().getBooleanResult("[var=a]<100"));
 
  assertTrue(getEvaluator().getBooleanResult("2<[var=a]"));
 
  assertTrue(getEvaluator().getBooleanResult("[var=a]<[var=b]"));
 
  assertTrue(!getEvaluator().getBooleanResult("[var=b]<[var=a]"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testLessThanWithInput() {
+
public void testLessThan3() {
  assertTrue(getEvaluator().getBooleanResult("2<[pos=1]"));
+
assertTrue(Evaluator.getBooleanResult("3.5<5.7", lessThanExerciseVariableMap, lessThanFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("[pos=2]<34"));
 
  assertTrue(!getEvaluator().getBooleanResult("2<[pos=2]"));
 
  assertTrue(!getEvaluator().getBooleanResult("22<[pos=1]"));
 
  assertTrue(getEvaluator().getBooleanResult("2<[pos=1]"));
 
  assertTrue(getEvaluator().getBooleanResult("[pos=2]<[pos=1]"));
 
  assertTrue(!getEvaluator().getBooleanResult("[pos=1]<[pos=2]"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testLessThanWithEncapsulation(){
+
public void testLessThan4() {
  assertTrue(!getEvaluator().getBooleanResult("1 < (1 < 2)"));
+
assertTrue(Evaluator.getBooleanResult("-1<1", lessThanExerciseVariableMap, lessThanFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("0 < (0 < (0 < 1))"));
 
  assertTrue(getEvaluator().getBooleanResult("0 < (0 < (0 < (0 < (0 < 1))))"));
 
  assertTrue(!getEvaluator().getBooleanResult("((((1 < 1) < 1) < 1) < 1) < 1"));
 
 
}
 
}
+
 
@Test(expected=ParserMismatchException.class)
+
@Test
 +
public void testLessThan5() {
 +
assertTrue(Evaluator.getBooleanResult("-0.2<0", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithExerciseVariables1() {
 +
assertTrue(Evaluator.getBooleanResult("8<[var=b]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithExerciseVariables2() {
 +
assertTrue(!Evaluator.getBooleanResult("9<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithExerciseVariables3() {
 +
assertTrue(!Evaluator.getBooleanResult("22<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithExerciseVariables4() {
 +
assertTrue(Evaluator.getBooleanResult("[var=a]<100", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithExerciseVariables5() {
 +
assertTrue(Evaluator.getBooleanResult("2<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithExerciseVariables6() {
 +
assertTrue(
 +
Evaluator.getBooleanResult("[var=a]<[var=b]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithExerciseVariables7() {
 +
assertTrue(
 +
!Evaluator.getBooleanResult("[var=b]<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithInput1() {
 +
assertTrue(Evaluator.getBooleanResult("2<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithInput2() {
 +
assertTrue(Evaluator.getBooleanResult("[pos=2]<34", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithInput3() {
 +
assertTrue(!Evaluator.getBooleanResult("2<[pos=2]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithInput4() {
 +
assertTrue(!Evaluator.getBooleanResult("22<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithInput5() {
 +
assertTrue(Evaluator.getBooleanResult("2<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithInput6() {
 +
assertTrue(
 +
Evaluator.getBooleanResult("[pos=2]<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithInput7() {
 +
assertTrue(
 +
!Evaluator.getBooleanResult("[pos=1]<[pos=2]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithEncapsulation1() {
 +
assertTrue(!Evaluator.getBooleanResult("1 < (1 < 2)", lessThanExerciseVariableMap, lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithEncapsulation2() {
 +
assertTrue(Evaluator.getBooleanResult("0 < (0 < (0 < 1))", lessThanExerciseVariableMap,
 +
lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithEncapsulation3() {
 +
assertTrue(Evaluator.getBooleanResult("0 < (0 < (0 < (0 < (0 < 1))))", lessThanExerciseVariableMap,
 +
lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanWithEncapsulation4() {
 +
assertTrue(!Evaluator.getBooleanResult("((((1 < 1) < 1) < 1) < 1) < 1", lessThanExerciseVariableMap,
 +
lessThanFillInVariableMap));
 +
}
 +
 
 +
@Test(expected = ParserException.class)
 
public void testLessThanWithWrongInputCharacter() {
 
public void testLessThanWithWrongInputCharacter() {
  getEvaluator().getBooleanResult("6 < a");
+
Evaluator.getBooleanResult("6 < ab", lessThanExerciseVariableMap, lessThanFillInVariableMap);
 
}
 
}
+
 
@Test(expected=UnsupportedBinaryOperatorException.class)
+
@Test(expected = FunctionInvalidArgumentTypeException.class)
 
public void testLessThanWithWrongInputString() {
 
public void testLessThanWithWrongInputString() {
  getEvaluator().getBooleanResult("6 < 'a'");
+
Evaluator.getBooleanResult("6 < 'a'", lessThanExerciseVariableMap, lessThanFillInVariableMap);
 +
fail();
 
}
 
}
+
 
@Test (expected=UndefinedExerciseVariableException.class)
+
@Test(expected = UndefinedExerciseVariableException.class)
 
public void testLessThanWithMissingExcerciseVariable() {
 
public void testLessThanWithMissingExcerciseVariable() {
  getEvaluator().getBooleanResult("[var=j] < 2");
+
Evaluator.getBooleanResult("[var=j] < 2", lessThanExerciseVariableMap, lessThanFillInVariableMap);
 +
fail();
 
}
 
}
+
 
@Test (expected=UndefinedFillInVariableException.class)
+
@Test(expected = UndefinedFillInVariableException.class)
 
public void testLessThanWithMissingInput() {
 
public void testLessThanWithMissingInput() {
  getEvaluator().getBooleanResult("[pos=42] < 2");
+
Evaluator.getBooleanResult("[pos=42] < 2", lessThanExerciseVariableMap, lessThanFillInVariableMap);
 +
fail();
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Version vom 19. September 2017, 07:30 Uhr

Beschreibung

Die Funktion lessThan 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 {
	lessThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
	lessThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));

	lessThanExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
	lessThanExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
}

@Test
public void testLessThan1() {
	assertTrue(Evaluator.getBooleanResult("8<22", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThan2() {
	assertTrue(!Evaluator.getBooleanResult("22<8", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThan3() {
	assertTrue(Evaluator.getBooleanResult("3.5<5.7", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThan4() {
	assertTrue(Evaluator.getBooleanResult("-1<1", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThan5() {
	assertTrue(Evaluator.getBooleanResult("-0.2<0", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithExerciseVariables1() {
	assertTrue(Evaluator.getBooleanResult("8<[var=b]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithExerciseVariables2() {
	assertTrue(!Evaluator.getBooleanResult("9<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithExerciseVariables3() {
	assertTrue(!Evaluator.getBooleanResult("22<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithExerciseVariables4() {
	assertTrue(Evaluator.getBooleanResult("[var=a]<100", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithExerciseVariables5() {
	assertTrue(Evaluator.getBooleanResult("2<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithExerciseVariables6() {
	assertTrue(
			Evaluator.getBooleanResult("[var=a]<[var=b]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithExerciseVariables7() {
	assertTrue(
			!Evaluator.getBooleanResult("[var=b]<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithInput1() {
	assertTrue(Evaluator.getBooleanResult("2<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithInput2() {
	assertTrue(Evaluator.getBooleanResult("[pos=2]<34", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithInput3() {
	assertTrue(!Evaluator.getBooleanResult("2<[pos=2]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithInput4() {
	assertTrue(!Evaluator.getBooleanResult("22<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithInput5() {
	assertTrue(Evaluator.getBooleanResult("2<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithInput6() {
	assertTrue(
			Evaluator.getBooleanResult("[pos=2]<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithInput7() {
	assertTrue(
			!Evaluator.getBooleanResult("[pos=1]<[pos=2]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithEncapsulation1() {
	assertTrue(!Evaluator.getBooleanResult("1 < (1 < 2)", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}

@Test
public void testLessThanWithEncapsulation2() {
	assertTrue(Evaluator.getBooleanResult("0 < (0 < (0 < 1))", lessThanExerciseVariableMap,
			lessThanFillInVariableMap));
}

@Test
public void testLessThanWithEncapsulation3() {
	assertTrue(Evaluator.getBooleanResult("0 < (0 < (0 < (0 < (0 < 1))))", lessThanExerciseVariableMap,
			lessThanFillInVariableMap));
}

@Test
public void testLessThanWithEncapsulation4() {
	assertTrue(!Evaluator.getBooleanResult("((((1 < 1) < 1) < 1) < 1) < 1", lessThanExerciseVariableMap,
			lessThanFillInVariableMap));
}

@Test(expected = ParserException.class)
public void testLessThanWithWrongInputCharacter() {
	Evaluator.getBooleanResult("6 < ab", lessThanExerciseVariableMap, lessThanFillInVariableMap);
}

@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testLessThanWithWrongInputString() {
	Evaluator.getBooleanResult("6 < 'a'", lessThanExerciseVariableMap, lessThanFillInVariableMap);
	fail();
}

@Test(expected = UndefinedExerciseVariableException.class)
public void testLessThanWithMissingExcerciseVariable() {
	Evaluator.getBooleanResult("[var=j] < 2", lessThanExerciseVariableMap, lessThanFillInVariableMap);
	fail();
}

@Test(expected = UndefinedFillInVariableException.class)
public void testLessThanWithMissingInput() {
	Evaluator.getBooleanResult("[pos=42] < 2", lessThanExerciseVariableMap, lessThanFillInVariableMap);
	fail();
}

Hinweise