package function.builtin.math;

import static testutil.TestUtilities.*;

import org.junit.Test;

import function.ArgumentValidator.*;
import sexpression.LispNumber;

public class MINUSTester {

    @Test
    public void testMinusWithOneNumber() {
        String input = "(- 27)";

        assertSExpressionsMatch(new LispNumber("-27"), evaluateString(input));
    }

    @Test
    public void testMinusWithTwoNumbers() {
        String input = "(- 5 3)";

        assertSExpressionsMatch(new LispNumber("2"), evaluateString(input));
    }

    @Test
    public void testMinusWithManyNumbers_PositiveResult() {
        String input = "(- 200 100 10 5)";

        assertSExpressionsMatch(new LispNumber("85"), evaluateString(input));
    }

    @Test
    public void testMinusWithManyNumbers_NegativeResult() {
        String input = "(- 100 200 20 5)";

        assertSExpressionsMatch(new LispNumber("-125"), evaluateString(input));
    }

    @Test(expected = BadArgumentTypeException.class)
    public void testMinusWithNonNumber() {
        evaluateString("(- 'a 'b)");
    }

    @Test(expected = TooFewArgumentsException.class)
    public void testMinusWithTooFewArguments() {
        evaluateString("(-)");
    }

}
