2017-01-14 18:01:14 -05:00
|
|
|
package function.builtin.predicate;
|
2017-01-04 13:57:16 -05:00
|
|
|
|
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import function.ArgumentValidator.*;
|
|
|
|
|
|
|
|
public class GREATERPTester {
|
|
|
|
|
2017-01-05 18:00:21 -05:00
|
|
|
@Test
|
|
|
|
public void testGreaterpWithOneNumber_ReturnsT() {
|
|
|
|
String input = "(> 1)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("t"), evaluateString(input));
|
2017-01-05 18:00:21 -05:00
|
|
|
}
|
|
|
|
|
2017-01-04 13:57:16 -05:00
|
|
|
@Test
|
|
|
|
public void testGreaterpWithTwoNumbers_ReturnsNil() {
|
|
|
|
String input = "(> 1 2)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("nil"), evaluateString(input));
|
2017-01-04 13:57:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGreaterpWithTwoNumbers_ReturnsT() {
|
|
|
|
String input = "(> 3 2)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("t"), evaluateString(input));
|
2017-01-04 13:57:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGreaterpWithManyNumbers_ReturnsNil() {
|
|
|
|
String input = "(> 4 3 2 5 1)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("nil"), evaluateString(input));
|
2017-01-04 13:57:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGreaterpWithManyNumbers_ReturnsT() {
|
|
|
|
String input = "(> 4 3 2 1 0)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("t"), evaluateString(input));
|
2017-01-04 13:57:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = BadArgumentTypeException.class)
|
|
|
|
public void testGreaterpWithNonNumbers() {
|
|
|
|
evaluateString("(> 'x 'x)");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = TooFewArgumentsException.class)
|
|
|
|
public void testGreaterpWithTooFewArguments() {
|
2017-01-05 18:00:21 -05:00
|
|
|
evaluateString("(>)");
|
2017-01-04 13:57:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|