@Before
public void beforeTest(){
placeFillInVariable(0, OMParser.parse("ll"));
placeFillInVariable(1, OMParser.parse("0"));
placeFillInVariable(2, OMParser.parse("hello"));
placeExerciseVariable("a", OMParser.parse("0"));
placeExerciseVariable("ll", OMParser.parse("ll"));
placeExerciseVariable("hello", OMParser.parse("hello"));
}
@Test public void testStartsWith(){
assertTrue(getEvaluator().getBooleanResult("startsWith('hello','he',0)"));
assertTrue(getEvaluator().getBooleanResult("startsWith('hello','ll',2)"));
assertTrue(getEvaluator().getBooleanResult("startsWith('hello','o',4)"));
assertTrue(!getEvaluator().getBooleanResult("startsWith('hello','ll',0)"));
assertTrue(getEvaluator().getBooleanResult("startsWith('','',0)"));
assertTrue(!getEvaluator().getBooleanResult("startsWith('',' ',0)"));
}
@Test public void testStartsWithInput(){
assertTrue(getEvaluator().getBooleanResult("startsWith('hello','he',[pos=1])"));
assertTrue(getEvaluator().getBooleanResult("startsWith('hello','[pos=0]',2)"));
assertTrue(getEvaluator().getBooleanResult("startsWith('[pos=2]','o',4)"));
}
@Test public void testStartsWithVariables(){
assertTrue(getEvaluator().getBooleanResult("startsWith('hello','he',[var=a])"));
assertTrue(getEvaluator().getBooleanResult("startsWith('hello','[var=ll]',2)"));
assertTrue(getEvaluator().getBooleanResult("startsWith('[var=hello]','o',4)"));
}
@Test(expected=InvalidEvaluatorFunctionArgumentException.class)
public void testStartsWithWithWrongInputCharacter(){
getEvaluator().getBooleanResult("startsWith(a)");
}
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testStartsWithWithOneArgument(){
getEvaluator().getBooleanResult("startsWith('hello')");
}
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testStartsWithWithTwoArguments(){
getEvaluator().getBooleanResult("startsWith('hello', 'he')");
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testStartsWithWithMissingExerciseVariable(){
getEvaluator().getBooleanResult("startsWith('[var=j]', '[var=j]', '[var=j]')");
}
@Test(expected=UndefinedFillInVariableException.class)
public void testStartsWithWithMissingInput(){
getEvaluator().getBooleanResult("startsWith('[pos=42]', '[pos=42]', '[pos=42]')");
}