Die Funktion erwartet eine Zahl, die Stelle an der das Element aus der Liste genommen wird und die Liste selbst. Es wird eine Zahl oder ein String zurückgegeben.
@BeforeClass
public static void beforeTest() {
OMOBJ zero = new OMOBJ();
OMOBJ mfour = new OMOBJ();
OMOBJ twenty = new OMOBJ();
zero.setOMI(OMCreator.createOMI(0));
mfour.setOMI(OMCreator.createOMI(-4));
twenty.setOMI(OMCreator.createOMI(20));
fillIn.put(1, zero);
fillIn.put(2, mfour);
fillIn.put(3, twenty);
exerVar.put("a", zero);
exerVar.put("b", mfour);
exerVar.put("c", twenty);
}
@Test
public void testGetFromOrderedSet1() {
assertTrue(3 == Evaluator.getNumberResult("getFromOrderedList('1', '{2;3;5;6}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSet2() {
assertTrue(-2.6 == Evaluator.getNumberResult("getFromOrderedList('0', '{3;5;6;-2.6}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSet3() {
assertTrue(0 == Evaluator.getNumberResult("getFromOrderedList('1', '{-2.6;3;5;0}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSet4() {
assertTrue(5 == Evaluator.getNumberResult("getFromOrderedList('3', '{-2.6;3;5;0}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSet5() {
assertTrue(1 == Evaluator.getNumberResult("getFromOrderedList('0', '{1;1;1;1}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSet6() {
assertTrue(1 == Evaluator.getNumberResult("getFromOrderedList('3', '{1;1;1;1}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSetWithInput1() {
assertTrue(20 == Evaluator.getNumberResult("getFromOrderedList('2', '{[pos=3];4;5}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSetWithInput2() {
assertTrue(-4 == Evaluator.getNumberResult("getFromOrderedList('0', '{[pos=3];4;5;[pos=2]}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSetWithInput3() {
assertTrue(-4 == Evaluator.getNumberResult("getFromOrderedList('[pos=1]', '{[pos=3];4;5;[pos=2]}')", exerVar,
fillIn));
}
@Test
public void testGetFromOrderedSetWithVariables1() {
assertTrue(20 == Evaluator.getNumberResult("getFromOrderedList('2', '{[var=c];4;5}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSetWithVariables2() {
assertTrue(-4 == Evaluator.getNumberResult("getFromOrderedList('0', '{[var=c];4;5;[var=b]}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSetWithVariables3() {
assertTrue(-4 == Evaluator.getNumberResult("getFromOrderedList('[var=a]', '{[var=c];4;5;[var=b]}')", exerVar,
fillIn));
}
@Test
public void testGetFromOrderedSetWithOneRationalAndOneTextArgument() {
assertTrue(4 == Evaluator.getNumberResult("getFromOrderedList('1', '{2;4;5}')", exerVar, fillIn));
}
@Test
public void testGetFromOrderedSetWithTwoTextArguments() {
assertTrue(4 == Evaluator.getNumberResult("getFromOrderedList('1', '{2;4;5}')", exerVar, fillIn));
}
@Test // (expected=FunctionInvalidArgumentTypeException.class) Now works, single chars
// are recognized as Variables
public void testGetFromOrderedSetWithWrongInputCharacters() {
assertEquals(OMCreator.createOMOBJ(OMCreator.createOMSTR("b")),
Evaluator.evaluate("getFromOrderedList('1', '{a;b;c;d}')", exerVar, fillIn));
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testGetFromOrderedSetWithWrongInputCharacterIndex() {
Evaluator.getNumberResult("getFromOrderedList('a', '{1;2;3;4}')", exerVar, fillIn);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testGetFromOrderedSetWithWrongInputDoubleIndex() {
Evaluator.getNumberResult("getFromOrderedList('5.5', '{1;2;3;4}')", exerVar, fillIn);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testGetFromOrderedSetWithWrongInputComma() {
Evaluator.getNumberResult("getFromOrderedList('3', '{1,5,3,7}')", exerVar, fillIn);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testGetFromOrderedSetWithOneArgument() {
Evaluator.getNumberResult("getFromOrderedList('7')", exerVar, fillIn);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testGetFromOrderedSetWithThreeArguments() {
Evaluator.getNumberResult("getFromOrderedList('4', '{3;1;-1}', '{12;-3}')", exerVar, fillIn);
}
@Test(expected = UndefinedFillInVariableException.class)
public void testGetFromOrderedSetWithMissingInput() {
Evaluator.getNumberResult("getFromOrderedList('2', '{[pos=42];4;5}')", exerVar, fillIn);
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testGetFromOrderedSetWithMissingExerciseVariable() {
Evaluator.getNumberResult("getFromOrderedList('2', '{[var=j];4;5}')", exerVar, fillIn);
}