transcendental-lisp/test/function/builtin/math/DIVIDETester.java

64 lines
1.4 KiB
Java

package function.builtin.math;
import static testutil.TestUtilities.*;
import org.junit.Test;
import function.ArgumentValidator.*;
public class DIVIDETester {
@Test
public void testDivideWithOne() {
String input = "(/ 1)";
assertSExpressionsMatch(parseString("1"), evaluateString(input));
}
@Test
public void testDivideWithTwo() {
String input = "(/ 2)";
assertSExpressionsMatch(parseString("0"), evaluateString(input));
}
@Test
public void testDivideTwoNumbers() {
String input = "(/ 24 3)";
assertSExpressionsMatch(parseString("8"), evaluateString(input));
}
@Test
public void testDivideSeveralNumbers() {
String input = "(/ 256 2 2 8)";
assertSExpressionsMatch(parseString("8"), evaluateString(input));
}
@Test
public void testDivideTwoNumbersWithRemainder() {
String input = "(/ 9 2)";
assertSExpressionsMatch(parseString("4"), evaluateString(input));
}
@Test
public void testDivideSeveralNumbersWithRemainder() {
String input = "(/ 19 2 5)";
assertSExpressionsMatch(parseString("1"), evaluateString(input));
}
@Test(expected = BadArgumentTypeException.class)
public void testDivideWithNonNumber() {
evaluateString("(/ 'x)");
}
@Test(expected = TooFewArgumentsException.class)
public void testDivideWithTooFewArguments() {
evaluateString("(/)");
}
}