(define test
    (macro (name code result)
        (progn
	    (printf "%s: " name)
	    (if (equal? code result)
		(printf "passed")
		(printf "FAILED")
	    )
	    (printf "\n")
        )
    )
)

(test "sprintf" (sprintf "%r %c %b" (rational 1 3) (complex 0 1) (bigint 1000)) "1/3 i 1000")

(test "rational-add" (rational-tostring (rational-add (rational 1 3) (rational 2 3))) "1/1")

(test "rational-subtract" (rational-tostring (rational-subtract (rational 1 3) (rational 2 3))) "-1/3")

(test "rational-multiply" (rational-tostring (rational-multiply (rational 1 3) (rational 2 3))) "2/9")

(test "rational-divide" (rational-tostring (rational-divide (rational 1 3) (rational 2 3))) "1/2")

(test "complex-add" (complex-tostring (complex-add (complex 1 0) (complex 0 1))) "1+i")

(test "complex-subtract" (complex-tostring (complex-subtract (complex 1 0) (complex 0 1))) "1-i")

(test "complex-multiply" (complex-tostring (complex-multiply (complex 0 1) (complex 0 1))) "-1")

(test "complex-divide" (complex-tostring (complex-divide (complex 6 6) (complex 3 3))) "2i")

(test "bigint-add" (bigint-tostring (bigint-add (bigint 1000) (bigint 2000))) "3000")

(test "bigint-subtract" (bigint-tostring (bigint-subtract (bigint 1000) (bigint 2000))) "-1000")

(test "bigint-multiply" (bigint-tostring (bigint-multiply (bigint 1000000) (bigint 1000000))) "1000000000000")

(test "bigint-divide" (bigint-tostring (bigint-divide (bigint 1000000) (bigint 1000))) "1000")
