NotEqual

Aus JACK Wiki
Zur Navigation springen Zur Suche springen

Beschreibung

Die Funktionen notEqual vergleicht zwei Ausdrücke auf Gleichheit miteinander. Wenn die beiden Ausdrücke nicht übereinstimmen gibt die Funktion true zurück, ansonsten false.

Syntax

a != b

Parameter

  • a - double
  • b - double

Return Value

  • Gibt einen Boolean zurück.

Beispiele

<math>4!=6</math>    --> returns true

JUnit Tests

[Anzeigen]

@BeforeClass
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
		UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
	notEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
	notEqualFillInVariableMap.put(2, ExpressionParser.parse("10", null, null));
	notEqualFillInVariableMap.put(3, ExpressionParser.parse("3.5", null, null));

	notEqualExerciseVariableMap.put("a", ExpressionParser.parse("3", null, null));
	notEqualExerciseVariableMap.put("b", ExpressionParser.parse("10", null, null));
	notEqualExerciseVariableMap.put("c", ExpressionParser.parse("3.5", null, null));
}

@Test
public void testNotEqual1() {
	assertTrue(Evaluator.getBooleanResult("1 != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual2() {
	assertTrue(Evaluator.getBooleanResult("30 != 7", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual3() {
	assertTrue(Evaluator.getBooleanResult("-10 != 3", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual4() {
	assertTrue(!Evaluator.getBooleanResult("1 != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual5() {
	assertTrue(!Evaluator.getBooleanResult("0 != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual6() {
	assertTrue(Evaluator.getBooleanResult("'a' != 'b'", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual7() {
	assertTrue(Evaluator.getBooleanResult("'' != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual8() {
	assertTrue(Evaluator.getBooleanResult("0 != ''", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqual9() {
	assertTrue(!Evaluator.getBooleanResult("0 != '0'", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithVariables1() {
	assertTrue(Evaluator.getBooleanResult("[var=a] != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithVariables2() {
	assertTrue(Evaluator.getBooleanResult("30 != [var=a]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithVariables3() {
	assertTrue(Evaluator.getBooleanResult("[var=a]!= [var=b]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithVariables4() {
	assertTrue(!Evaluator.getBooleanResult("[var=a] != [var=a]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithInput1() {
	assertTrue(Evaluator.getBooleanResult("[pos=1] != 0", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithInput2() {
	assertTrue(Evaluator.getBooleanResult("30 != [pos=1]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithInput3() {
	assertTrue(Evaluator.getBooleanResult("[pos=1] != [pos=2]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithInput4() {
	assertTrue(!Evaluator.getBooleanResult("[pos=1] != [pos=1]", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation1() {
	assertFalse(Evaluator.getBooleanResult("1 != (1 != 0)", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation2() {
	assertTrue(Evaluator.getBooleanResult("1 != (1 != (1 != 0))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation3() {
	assertTrue(Evaluator.getBooleanResult("1 != (1 != (1 != (1 != (1 != 0))))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation4() {
	assertFalse(Evaluator.getBooleanResult("1 != (1 != (1 != (1 != (1 != 1))))", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation5() {
	assertTrue(Evaluator.getBooleanResult("((((1 != 0) != 1) != 1) != 1) != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test
public void testNotEqualWithEncapsulation6() {
	assertFalse(Evaluator.getBooleanResult("((((1 != 1) != 1) != 1) != 1) != 1", notEqualExerciseVariableMap, notEqualFillInVariableMap));
}

@Test(expected=ParserException.class)
public void testNotEqualWithWrongInputCharacter() {
	Evaluator.getBooleanResult("1 == ab", notEqualExerciseVariableMap, notEqualFillInVariableMap);
	fail();
}

@Test (expected=UndefinedExerciseVariableException.class)
public void testNotEqualWithMissingExcerciseVariable() {
	Evaluator.getBooleanResult("[var=j] == 2", notEqualExerciseVariableMap, notEqualFillInVariableMap);
	fail();
}

@Test (expected=UndefinedFillInVariableException.class)
public void testNotEqualWithMissingInput() {
	Evaluator.getBooleanResult("[pos=42] == 2", notEqualExerciseVariableMap, notEqualFillInVariableMap);
	fail();
}

Hinweise