/* Test whether a basic cargl invocation works. */ /* This test is generated by misc/genbasic.c. */ #include #include #include #include #include "../basic.h" #pragma STDC FENV_ACCESS ON #define MF_UNSPEC1 (1 << 0) #define MF_UNSPEC2 (1 << 1) #define MF_MAYERR (1 << 2) #define MF_ANYSIGN1 (1 << 2) #define MF_ANYSIGN2 (1 << 3) // Soft fail on rounding errors and report only one. int imprecise; void test(int variant, long double complex input1, long double lower, long double expected, long double upper, int flags) { long double output = cargl(input1); if ( !(flags & MF_UNSPEC1) ) { if ( !(isnan(expected) ? isnan(output) : isfinite(expected) && expected != 0.0 ? isfinite(output) && (output == expected || (lower < output && output < upper)) : output == expected) ) { if ( imprecise && isfinite(output) && isfinite(expected) ) return; warnx("(%d.) cargl(%.4Lf + i*%.4Lf) = %.17La, not %.17La, diff %.17La, ratio %.20Lg", variant, creall(input1), cimagl(input1), output, expected, output - expected, output / expected); if ( !isfinite(output) || !isfinite(expected) ) exit(1); imprecise = 1; } } } int main(void) { test(1, CMPLXL(90.01, 13.37), 0x9.6fff98f3e8e5142p-6L, 0x9.6fff98f3e8e5143p-6L, 0x9.6fff98f3e8e5144p-6L, 0); test(2, CMPLXL(-12.34, 13.37), 0x9.43bdc9a55e5ecdp-2L, 0x9.43bdc9a55e5ecd1p-2L, 0x9.43bdc9a55e5ecd2p-2L, 0); test(3, CMPLXL(nanl(""), 13.37), nanl(""), nanl(""), nanl(""), 0); test(4, CMPLXL(strtold("inf", NULL), 13.37), -0x0.000000000000001p-16385L, 0x0.0p+0L, 0x0.000000000000001p-16385L, 0); test(5, CMPLXL(strtold("-inf", NULL), 13.37), 0xc.90fdaa22168c234p-2L, 0xc.90fdaa22168c235p-2L, 0xc.90fdaa22168c236p-2L, 0); test(6, CMPLXL(0.0, 13.37), 0xc.90fdaa22168c234p-3L, 0xc.90fdaa22168c235p-3L, 0xc.90fdaa22168c236p-3L, 0); test(7, CMPLXL(90.01, -12.34), -0x8.b843508193366c3p-6L, -0x8.b843508193366c2p-6L, -0x8.b843508193366c1p-6L, 0); test(8, CMPLXL(-12.34, -12.34), -0x9.6cbe3f9990e91a9p-2L, -0x9.6cbe3f9990e91a8p-2L, -0x9.6cbe3f9990e91a7p-2L, 0); test(9, CMPLXL(nanl(""), -12.34), nanl(""), nanl(""), nanl(""), 0); test(10, CMPLXL(strtold("inf", NULL), -12.34), -0x0.000000000000001p-16385L, -0x0.0p+0L, 0x0.000000000000001p-16385L, 0); test(11, CMPLXL(strtold("-inf", NULL), -12.34), -0xc.90fdaa22168c236p-2L, -0xc.90fdaa22168c235p-2L, -0xc.90fdaa22168c234p-2L, 0); test(12, CMPLXL(0.0, -12.34), -0xc.90fdaa22168c236p-3L, -0xc.90fdaa22168c235p-3L, -0xc.90fdaa22168c234p-3L, 0); test(13, CMPLXL(90.01, nanl("")), nanl(""), nanl(""), nanl(""), 0); test(14, CMPLXL(-12.34, nanl("")), nanl(""), nanl(""), nanl(""), 0); test(15, CMPLXL(nanl(""), nanl("")), nanl(""), nanl(""), nanl(""), 0); test(16, CMPLXL(strtold("inf", NULL), nanl("")), nanl(""), nanl(""), nanl(""), 0); test(17, CMPLXL(strtold("-inf", NULL), nanl("")), nanl(""), nanl(""), nanl(""), 0); test(18, CMPLXL(0.0, nanl("")), nanl(""), nanl(""), nanl(""), 0); test(19, CMPLXL(90.01, strtold("inf", NULL)), 0xc.90fdaa22168c234p-3L, 0xc.90fdaa22168c235p-3L, 0xc.90fdaa22168c236p-3L, 0); test(20, CMPLXL(-12.34, strtold("inf", NULL)), 0xc.90fdaa22168c234p-3L, 0xc.90fdaa22168c235p-3L, 0xc.90fdaa22168c236p-3L, 0); test(21, CMPLXL(nanl(""), strtold("inf", NULL)), nanl(""), nanl(""), nanl(""), 0); test(22, CMPLXL(strtold("inf", NULL), strtold("inf", NULL)), 0xc.90fdaa22168c234p-4L, 0xc.90fdaa22168c235p-4L, 0xc.90fdaa22168c236p-4L, 0); test(23, CMPLXL(strtold("-inf", NULL), strtold("inf", NULL)), 0x9.6cbe3f9990e91a7p-2L, 0x9.6cbe3f9990e91a8p-2L, 0x9.6cbe3f9990e91a9p-2L, 0); test(24, CMPLXL(0.0, strtold("inf", NULL)), 0xc.90fdaa22168c234p-3L, 0xc.90fdaa22168c235p-3L, 0xc.90fdaa22168c236p-3L, 0); test(25, CMPLXL(90.01, strtold("-inf", NULL)), -0xc.90fdaa22168c236p-3L, -0xc.90fdaa22168c235p-3L, -0xc.90fdaa22168c234p-3L, 0); test(26, CMPLXL(-12.34, strtold("-inf", NULL)), -0xc.90fdaa22168c236p-3L, -0xc.90fdaa22168c235p-3L, -0xc.90fdaa22168c234p-3L, 0); test(27, CMPLXL(nanl(""), strtold("-inf", NULL)), nanl(""), nanl(""), nanl(""), 0); test(28, CMPLXL(strtold("inf", NULL), strtold("-inf", NULL)), -0xc.90fdaa22168c236p-4L, -0xc.90fdaa22168c235p-4L, -0xc.90fdaa22168c234p-4L, 0); test(29, CMPLXL(strtold("-inf", NULL), strtold("-inf", NULL)), -0x9.6cbe3f9990e91a9p-2L, -0x9.6cbe3f9990e91a8p-2L, -0x9.6cbe3f9990e91a7p-2L, 0); test(30, CMPLXL(0.0, strtold("-inf", NULL)), -0xc.90fdaa22168c236p-3L, -0xc.90fdaa22168c235p-3L, -0xc.90fdaa22168c234p-3L, 0); test(31, CMPLXL(90.01, 0.0), -0x0.000000000000001p-16385L, 0x0.0p+0L, 0x0.000000000000001p-16385L, 0); test(32, CMPLXL(-12.34, 0.0), 0xc.90fdaa22168c234p-2L, 0xc.90fdaa22168c235p-2L, 0xc.90fdaa22168c236p-2L, 0); test(33, CMPLXL(nanl(""), 0.0), nanl(""), nanl(""), nanl(""), 0); test(34, CMPLXL(strtold("inf", NULL), 0.0), -0x0.000000000000001p-16385L, 0x0.0p+0L, 0x0.000000000000001p-16385L, 0); test(35, CMPLXL(strtold("-inf", NULL), 0.0), 0xc.90fdaa22168c234p-2L, 0xc.90fdaa22168c235p-2L, 0xc.90fdaa22168c236p-2L, 0); test(36, CMPLXL(0.0, 0.0), -0x0.000000000000001p-16385L, 0x0.0p+0L, 0x0.000000000000001p-16385L, 0); return imprecise; }