Пример #1
0
int
main(int argc, char *argv[])
{
    int rmodes[] = { FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO };
    int i;

    printf("1..19\n");

    for (i = 0; i < 4; i++) {
        fesetround(rmodes[i]);
        test_zeroes();
        printf("ok %d - fma zeroes\n", i + 1);
    }

    for (i = 0; i < 4; i++) {
        fesetround(rmodes[i]);
        test_infinities();
        printf("ok %d - fma infinities\n", i + 5);
    }

    fesetround(FE_TONEAREST);
    test_nans();
    printf("ok 9 - fma NaNs\n");

    for (i = 0; i < 4; i++) {
        fesetround(rmodes[i]);
        test_small_z();
        printf("ok %d - fma small z\n", i + 10);
    }

    for (i = 0; i < 4; i++) {
        fesetround(rmodes[i]);
        test_big_z();
        printf("ok %d - fma big z\n", i + 14);
    }

    fesetround(FE_TONEAREST);
    test_accuracy();
    printf("ok 18 - fma accuracy\n");

    test_double_rounding();
    printf("ok 19 - fma double rounding\n");

    /*
     * TODO:
     * - Tests for subnormals
     * - Cancellation tests (e.g., z = (double)x*y, but x*y is inexact)
     */

    return (0);
}
Пример #2
0
int
main(int argc, char *argv[])
{

	printf("1..15\n");

	/* Test csqrt() */
	t_csqrt = _csqrt;

	test_finite();
	printf("ok 1 - csqrt\n");

	test_zeros();
	printf("ok 2 - csqrt\n");

	test_infinities();
	printf("ok 3 - csqrt\n");

	test_nans();
	printf("ok 4 - csqrt\n");

	test_overflow(DBL_MAX_EXP);
	printf("ok 5 - csqrt\n");

	/* Now test csqrtf() */
	t_csqrt = _csqrtf;

	test_finite();
	printf("ok 6 - csqrt\n");

	test_zeros();
	printf("ok 7 - csqrt\n");

	test_infinities();
	printf("ok 8 - csqrt\n");

	test_nans();
	printf("ok 9 - csqrt\n");

	test_overflow(FLT_MAX_EXP);
	printf("ok 10 - csqrt\n");

	/* Now test csqrtl() */
	t_csqrt = csqrtl;

	test_finite();
	printf("ok 11 - csqrt\n");

	test_zeros();
	printf("ok 12 - csqrt\n");

	test_infinities();
	printf("ok 13 - csqrt\n");

	test_nans();
	printf("ok 14 - csqrt\n");

	test_overflow(LDBL_MAX_EXP);
	printf("ok 15 - csqrt\n");

	return (0);
}
Пример #3
0
int
main(void)
{
	int rmodes[] = { FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO };
	unsigned i, j;

#if defined(__i386__)
	printf("1..0 # SKIP all testcases fail on i386\n");
	exit(0);
#endif

	j = 1;

	printf("1..19\n");

	for (i = 0; i < nitems(rmodes); i++, j++) {
		printf("rmode = %d\n", rmodes[i]);
		fesetround(rmodes[i]);
		test_zeroes();
		printf("ok %d - fma zeroes\n", j);
	}

	for (i = 0; i < nitems(rmodes); i++, j++) {
#if defined(__amd64__)
		printf("ok %d # SKIP testcase fails assertion on "
		    "amd64\n", j);
		continue;
#else
		printf("rmode = %d\n", rmodes[i]);
		fesetround(rmodes[i]);
		test_infinities();
		printf("ok %d - fma infinities\n", j);
#endif
	}

	fesetround(FE_TONEAREST);
	test_nans();
	printf("ok %d - fma NaNs\n", j);
	j++;

	for (i = 0; i < nitems(rmodes); i++, j++) {
		printf("rmode = %d\n", rmodes[i]);
		fesetround(rmodes[i]);
		test_small_z();
		printf("ok %d - fma small z\n", j);
	}

	for (i = 0; i < nitems(rmodes); i++, j++) {
		printf("rmode = %d\n", rmodes[i]);
		fesetround(rmodes[i]);
		test_big_z();
		printf("ok %d - fma big z\n", j);
	}

	fesetround(FE_TONEAREST);
	test_accuracy();
	printf("ok %d - fma accuracy\n", j);
	j++;

	test_double_rounding();
	printf("ok %d - fma double rounding\n", j);
	j++;

	/*
	 * TODO:
	 * - Tests for subnormals
	 * - Cancellation tests (e.g., z = (double)x*y, but x*y is inexact)
	 */

	return (0);
}