mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-02 19:29:21 +00:00
Add tests for fp comparison macros and type-generic math macros.
This commit is contained in:
parent
d0514c5dc4
commit
8c5fba684c
@ -19,6 +19,8 @@
|
|||||||
{1} c99locale.c
|
{1} c99locale.c
|
||||||
{1} c99stdarg.c
|
{1} c99stdarg.c
|
||||||
{1} c99math.c
|
{1} c99math.c
|
||||||
|
{1} c99fpcmp.c
|
||||||
|
{1} c99tgmath.c
|
||||||
{1} c11generic.c
|
{1} c11generic.c
|
||||||
{1} c11align.c
|
{1} c11align.c
|
||||||
{1} c11noret.c
|
{1} c11noret.c
|
||||||
@ -26,4 +28,3 @@
|
|||||||
{1} c11sassert.c
|
{1} c11sassert.c
|
||||||
{1} c11unicode.c
|
{1} c11unicode.c
|
||||||
{1} c11uchar.c
|
{1} c11uchar.c
|
||||||
|
|
||||||
|
92
Tests/Conformance/c99fpcmp.c
Normal file
92
Tests/Conformance/c99fpcmp.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Test floating-point comparison macros (C99).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fenv.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
float nan_ = NAN;
|
||||||
|
|
||||||
|
#pragma STDC FENV_ACCESS ON
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
if (!isgreater(1.0, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
if (isgreater(-5e20L, -5e20L))
|
||||||
|
goto Fail;
|
||||||
|
if (isgreater(5.0F, 7.0F))
|
||||||
|
goto Fail;
|
||||||
|
if (isgreater(nan_, 1.0L))
|
||||||
|
goto Fail;
|
||||||
|
if (isgreater(-INFINITY, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (!isgreaterequal(1.0, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
if (!isgreaterequal(-5e20L, -5e20L))
|
||||||
|
goto Fail;
|
||||||
|
if (isgreaterequal(5.0F, 7.0F))
|
||||||
|
goto Fail;
|
||||||
|
if (isgreaterequal(nan_, 1.0L))
|
||||||
|
goto Fail;
|
||||||
|
if (isgreaterequal(-INFINITY, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (isless(1.0, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
if (isless(-5e20L, -5e20L))
|
||||||
|
goto Fail;
|
||||||
|
if (!isless(5.0F, 7.0F))
|
||||||
|
goto Fail;
|
||||||
|
if (isless(nan_, 1.0L))
|
||||||
|
goto Fail;
|
||||||
|
if (!isless(-INFINITY, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (islessequal(1.0, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
if (!islessequal(-5e20L, -5e20L))
|
||||||
|
goto Fail;
|
||||||
|
if (!islessequal(5.0F, 7.0F))
|
||||||
|
goto Fail;
|
||||||
|
if (islessequal(nan_, 1.0L))
|
||||||
|
goto Fail;
|
||||||
|
if (!islessequal(-INFINITY, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (!islessgreater(1.0, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
if (islessgreater(-5e20L, -5e20L))
|
||||||
|
goto Fail;
|
||||||
|
if (!islessgreater(5.0F, 7.0F))
|
||||||
|
goto Fail;
|
||||||
|
if (islessgreater(nan_, 1.0L))
|
||||||
|
goto Fail;
|
||||||
|
if (!islessgreater(-INFINITY, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (isunordered(1.0, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
if (isunordered(-5e20L, -5e20L))
|
||||||
|
goto Fail;
|
||||||
|
if (isunordered(5.0F, 7.0F))
|
||||||
|
goto Fail;
|
||||||
|
if (!isunordered(nan_, 1.0L))
|
||||||
|
goto Fail;
|
||||||
|
if (isunordered(-INFINITY, -3.0))
|
||||||
|
goto Fail;
|
||||||
|
if (!isunordered(INFINITY, nan_))
|
||||||
|
goto Fail;
|
||||||
|
if (!isunordered(nan_, nan_))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (fetestexcept(FE_INVALID))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
printf ("Passed Conformance Test c99fpcmp\n");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Fail:
|
||||||
|
printf ("Failed Conformance Test c99fpcmp\n");
|
||||||
|
}
|
85
Tests/Conformance/c99tgmath.c
Normal file
85
Tests/Conformance/c99tgmath.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Test <tgmath.h> macros (C99).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <tgmath.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
if (cos(0.0) != 1.0)
|
||||||
|
goto Fail;
|
||||||
|
if (copysign(1.0L, -3e10F) != -1.0L)
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (sizeof(sin(0.0)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(tan(0.5F)) != sizeof(float))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(log(2.0L)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(exp(5)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(sqrt(7LL)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (sizeof(fmax(1.0F, 20.0F)) != sizeof(float))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fmin(1.0F, 20.0)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fdim(1.0F, 20.0L)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(hypot(1.0F, 20)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(nextafter(1.0F, 20LL)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (sizeof(fmax(1.0, 20.0F)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fmin(1.0, 20.0)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fdim(1.0, 20.0L)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(hypot(1.0, 20)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(nextafter(1.0, 20LL)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (sizeof(fmax(1.0L, 20.0F)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fmin(1.0L, 20.0)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fdim(1.0L, 20.0L)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(hypot(1.0L, 20)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(nextafter(1.0L, 20LL)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (sizeof(fmax(1, 20.0F)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fmin(1, 20.0)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fdim(1, 20.0L)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(hypot(1, 20)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(nextafter(1, 20LL)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
if (sizeof(fmax(1LL, 20.0F)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fmin(1LL, 20.0)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(fdim(1LL, 20.0L)) != sizeof(long double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(hypot(1LL, 20)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
if (sizeof(nextafter(1LL, 20LL)) != sizeof(double))
|
||||||
|
goto Fail;
|
||||||
|
|
||||||
|
printf ("Passed Conformance Test c99tgmath\n");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Fail:
|
||||||
|
printf ("Failed Conformance Test c99tgmath\n");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user