예제 #1
0
void test_integer()
{
	// Implement sub with only add
	test_subtract();

	// Implement mul with only add
	test_multiply();

	// Implement div with only add
	test_divide();

	// Reverse digits of an integer
	test_reverseInteger();

	// Determine whether an integer is a palindrome. Do this without extra space
	test_isPalindrome<IsPalindromeIterative>();
	test_isPalindrome<IsPalindromeRecursion>();
}
예제 #2
0
파일: dec64_test.c 프로젝트: kmsquire/DEC64
void test_all_multiply() {
    test_multiply(nan, nan, nan, "nan * nan");
    test_multiply(nan, zero, zero, "nan * zero");
    test_multiply(nannan, nannan, nan, "nannan * nannan");
    test_multiply(nannan, one, nan, "nannan * 1");
    test_multiply(zero, nan, zero, "0 * nan");
    test_multiply(zero, nannan, zero, "0 * nannan");
    test_multiply(zero, zip, zero, "zero * zip");
    test_multiply(zero, maxnum, zero, "zero * maxnum");
    test_multiply(zip, zero, zero, "zip * zero");
    test_multiply(zip, zip, zero, "zip * zip");
    test_multiply(minnum, minnum, zero, "minnum * minnum");
    test_multiply(epsilon, epsilon, dec64_new(1, -32), "epsilon * epsilon");
    test_multiply(one, nannan, nan, "1 * nannan");
    test_multiply(negative_one, one, negative_one, "-1 * 1");
    test_multiply(negative_one, negative_one, one, "-1 * -1");
    test_multiply(two, five, ten, "2 * 5");
    test_multiply(two, maxnum, nan, "2 * maxnum");
    test_multiply(two, dec64_new(36028797018963967, 126), dec64_new(7205759403792793, 127), "2 * a big one");
    test_multiply(three, two, six, "3 * 2");
    test_multiply(ten, dec64_new(36028797018963967, 126), maxnum, "10 * a big one");
    test_multiply(ten, dec64_new(1, 127), dec64_new(10, 127), "10 * 1e127");
    test_multiply(dec64_new(1, 2), dec64_new(1, 127), dec64_new(100, 127), "1e2 * 1e127");
    test_multiply(dec64_new(1, 12), dec64_new(1, 127), dec64_new(1000000000000, 127), "1e2 * 1e127");
    test_multiply(dec64_new(1, 12), dec64_new(1, 127), dec64_new(1000000000000, 127), "1e12 * 1e127");
    test_multiply(dec64_new(3, 16), dec64_new(1, 127), dec64_new(30000000000000000, 127), "3e16 * 1e127");
    test_multiply(dec64_new(3, 17), dec64_new(1, 127), nan, "3e16 * 1e127");
    test_multiply(dec64_new(-3, 16), dec64_new(1, 127), dec64_new(-30000000000000000, 127), "3e16 * 1e127");
    test_multiply(dec64_new(-3, 17), dec64_new(1, 127), nan, "3e16 * 1e127");
    test_multiply(dec64_new(9999999999999999, 0), ten, dec64_new(9999999999999999, 1), "9999999999999999 * 10");
    test_multiply(maxint, zero, zero, "maxint * zero");
    test_multiply(maxint, epsilon, dec64_new(36028797018963967, -16), "maxint * epsilon");
    test_multiply(maxint, maxint, dec64_new(12980742146337068, 17), "maxint * maxint");
    test_multiply(negative_maxint, nan, nan, "-maxint * nan");
    test_multiply(negative_maxint, maxint, dec64_new(-12980742146337069, 17), "-maxint * maxint");
    test_multiply(maxnum, maxnum, nan, "maxnum * maxnum");
    test_multiply(maxnum, minnum, maxint, "maxnum * minnum");
}
void
selftest(void)
{
	// for handling "errout"

	if (setjmp(jbuf))
		return;

#if SELFTEST

	test_low_level();

	test_multiply();
	test_scan();
	test_power();
	test_factor_number();
	test_test();
	test_tensor();

	test_bake();

	test(__FILE__, s, sizeof (s) / sizeof (char *)); // "s" is in selftest.h

	test_abs();
	test_adj();
	test_arg();
	test_besselj();
	test_bessely();
	test_ceiling();
	test_choose();
	test_circexp();
	test_clock();
	test_cofactor();
	test_condense();
	test_contract();
	test_defint();
	test_denominator();
	test_derivative();
	test_dirac();
	test_erf();
	test_erfc();
	test_expand();
	test_expcos();
	test_expsin();
	test_factorpoly();
	test_float();
	test_floor();
	test_gamma();
	test_gcd();
	test_imag();
	test_inner();
	test_lcm();
	test_log();
	test_mag();
	test_mod();
	test_nroots();
	test_numerator();
	test_outer();
	test_polar();
	test_quotient();
	test_rationalize();
	test_real();
	test_rect();
	test_sgn();
	test_taylor();
	test_transpose();
	test_zero();

	test_hermite();
	test_laguerre();
	test_legendre();
	test_binomial();
	test_divisors();
	test_coeff();
	test_sin();
	test_cos();
	test_tan();
	test_sinh();
	test_cosh();
	test_tanh();
	test_arcsin();
	test_arcsinh();
	test_arccos();
	test_arccosh();
	test_arctan();
	test_arctanh();
	test_index();
	test_isprime();
	test_integral();
	test_simplify();
	test_roots();
	test_eigen();

#endif

	mini_test();

	logout("OK, all tests passed.\n");
}