Die Funktion erwartet eine Zahl, die Stelle an der das Element aus der Liste genommen wird, und eine Liste, aus der das Element gezogen werden soll. Es wird das erwartete Element zurückgegeben.
@BeforeClass
public static void beforeTest() {
OMOBJ zero = new OMOBJ();
OMOBJ two = new OMOBJ();
OMOBJ mtwo = new OMOBJ();
OMOBJ e = new OMOBJ();
e.setOMV(OMCreator.createOMV("e"));
zero.setOMI(OMCreator.createOMI(0));
two.setOMI(OMCreator.createOMI(2));
mtwo.setOMI(OMCreator.createOMI(-2));
fillIn.put(1, zero);
fillIn.put(2, two);
fillIn.put(3, mtwo);
fillIn.put(4, e);
exerVar.put("a", zero);
exerVar.put("b", two);
exerVar.put("c", mtwo);
exerVar.put("d", e);
}
@Test
public void testGetFromSet1() {
assertEquals(2, Evaluator.getNumberResult("getFromList('1', '{1;2;3}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSet2() {
assertEquals(true, Evaluator.getBooleanResult("'c' == getFromList('2', '{a;b;c}')", exerVar, fillIn));
}
@Test
public void testGetFromSet3() {
assertEquals(42, Evaluator.getNumberResult("getFromList('3', {a;12;'lalilu';42;-1})", exerVar, fillIn), 0);
}
@Test
public void testGetFromSet4() {
assertEquals(true, Evaluator.getBooleanResult(" '}' ==getFromList('1', {2;'}';3})", exerVar, fillIn));
}
@Test
public void testGetFromSet5() {
assertEquals(3, Evaluator.getNumberResult("getFromList('2', {2;'}';3})", exerVar, fillIn), 0);
}
@Test
public void testGetFromSet6() {
assertEquals(2, Evaluator.getNumberResult("getFromList('1', '{1;2;3}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSet7() {
assertEquals(true, Evaluator.getBooleanResult("'c' == getFromList('2', '{a;b;c}')", exerVar, fillIn));
}
@Test
public void testGetFromSet8() {
assertEquals(42, Evaluator.getNumberResult("getFromList('3', {a;12;'lalilu';42;-1})", exerVar, fillIn), 0);
}
@Test
public void testGetFromSet9() {
OMOBJ expected = new OMOBJ();
expected.setOMSTR(OMCreator.createOMSTR("1,3,2,7"));
assertEquals(expected, (Evaluator.evaluate("getFromList('0', {'1,3,2,7'})", exerVar, fillIn)));
}
@Test
public void testGetFromSetWithInput1() {
assertEquals(0, Evaluator.getNumberResult("getFromList('0', '{[pos=1];2;3}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSetWithInput2() {
assertEquals(-2, Evaluator.getNumberResult("getFromList('[pos=1]', '{[pos=3];2;3}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSetWithInput3() {
assertEquals(true,
Evaluator.getBooleanResult("'e' == getFromList('[pos=2]', '{a;b;[pos=4]}')", exerVar, fillIn));
}
@Test
public void testGetFromSetWithVariables1() {
assertEquals(0, Evaluator.getNumberResult("getFromList('0', '{[var=a];2;3}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSetWithVariables2() {
assertEquals(-2, Evaluator.getNumberResult("getFromList('[var=a]', '{[var=c];2;3}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSetWithVariables3() {
assertEquals(true,
Evaluator.getBooleanResult("'e' == getFromList('[var=b]', '{a;b;[var=d]}')", exerVar, fillIn));
}
@Test
public void testGetFromSetWithPointNumber1() {
assertEquals(3.2, Evaluator.getNumberResult("getFromList('0', '{3.2;2;3}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSetWithPointNumber2() {
assertEquals(-2.2, Evaluator.getNumberResult("getFromList('[var=a]', '{-2.2;2;3}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSetWithPointNumber3() {
assertEquals(true, Evaluator.getBooleanResult("'e.a' == getFromList('2', {a;b;'e.a'})", exerVar, fillIn));
}
@Test
public void testGetFromSetWithOneRationalAndOneTextArgument() {
assertEquals(4, Evaluator.getNumberResult("getFromList('1', '{2;4;5}')", exerVar, fillIn), 0);
}
@Test
public void testGetFromSetWithTwoTextArguments() {
assertEquals(4, Evaluator.getNumberResult("getFromList('1', '{2;4;5}')", exerVar, fillIn), 0);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testGetFromSetWithOneArgument() {
Evaluator.getNumberResult("getFromList('3')", exerVar, fillIn);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testGetFromSetWithThreeArguments() {
Evaluator.getNumberResult("getFromList('4', '{3;1;-7}', '{12;-12}')", exerVar, fillIn);
}
@Test(expected = UndefinedFillInVariableException.class)
public void testGetFromSetWithMissingInput() {
Evaluator.getNumberResult("getFromList('2', '{[pos=42];4;5}')", exerVar, fillIn);
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testGetFromSetWithMissingExerciseVariable() {
Evaluator.getNumberResult("getFromList('2', '{[var=j];4;5}')", exerVar, fillIn);
}