#include "testconfig.h"
#define TEST_FUNC_F_F __MATH_PRECNAME(cbrt)
#include "testdriver.h"



static test_f_f_data const cbrt_data[] = {
	/* If x is +0, -0, positive infinity, negative infinity, or NaN, x is returned. */
	{ __LINE__, ZERO_P, ZERO_P, 0 },
	{ __LINE__, ZERO_M, ZERO_M, FLAG_FAIL_ARANYM2 },
	{ __LINE__, INF_P, INF_P, FLAG_FAIL_ARANYM2 },
	{ __LINE__, INF_M, INF_M, FLAG_FAIL_ARANYM2 }, /* sometimes returns NaN */
	{ __LINE__, QNAN_P, QNAN_P, 0 },
	{ __LINE__, QNAN_M, QNAN_P, 0 },
	{ __LINE__, SNAN_P, QNAN_P, 0 },
	{ __LINE__, SNAN_M, QNAN_P, 0 },

	{ __LINE__, HEXCONSTE(-1, 0xbfff, 0x80000000L, 0x00000000L), HEXCONSTE(-1, 0xbfff, 0x80000000L, 0x00000000L), FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* very inexact */ /* fails with FPU + with gcc 8.3 */
	{ __LINE__, HEXCONSTE(-1.1, 0xbfff, 0x8cccccccL, 0xcccccccdL), HEXCONSTE(-1.0322801154563671591907e+00, 0xbfff, 0x8421c13cL, 0x191d1dd0L), FLAG_INEXACT|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* very inexact */ /* fails with FPU + with gcc 8.3 */
#if defined(TEST_LDOUBLE) && LDBL_MANT_DIG >= 64
	{ __LINE__, HEXCONSTE(-3.36210314311209350626e-4932, 0x8001, 0x80000000L, 0x00000000L), HEXCONSTE(-1.4980869156445771586875e-1644, 0xaaaa, 0xa14517ccL, 0x6b945711L), 0 },
	{ __LINE__, MAX_M, HEXCONSTE(-1.0596187947380832725013e+1644, 0xd554, 0xa14517ccL, 0x6b945711L), 0 },
#endif
#if defined(TEST_DOUBLE)
	{ __LINE__, HEXCONSTE(-2.2250738585072014e-308L, 0xbc01, 0x80000000L, 0x00000046L), HEXCONSTE(-2.8126442852362619617738e-103, 0xbeaa, 0xa14517ccL, 0x6b945800L), FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* very inexact */ /* fails with FPU + with gcc 8.3 */
	{ __LINE__, HEXCONSTE(1.7976931348623157e+308L, 0x43fe, 0xffffffffL, 0xfffff7acL), HEXCONSTE(5.6438030941223632930333e+102, 0x4154, 0xa14517ccL, 0x6b945800L), FLAG_INEXACT|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* very inexact */ /* fails with FPU + with gcc 8.3 */
#endif
	{ __LINE__, SUBNORM_M, QNAN_P, FLAG_SUBNORM },

	{ __LINE__, HEXCONSTE(-0.001L, 0xbff5, 0x83126e97L, 0x8d4fdf3bL), HEXCONSTE(-0.1L, 0xbffb, 0xccccccccL, 0xcccccccdL), FLAG_INEXACT|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* fails with FPU + with gcc 8.3 */
	{ __LINE__, HEXCONSTE(8, 0x4002, 0x80000000L, 0x00000000L), HEXCONSTE(2, 0x4000, 0x80000000L, 0x00000000L), FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* fails with FPU + with gcc 8.3 */
	{ __LINE__, HEXCONSTE(-27.0, 0xc003, 0xd8000000L, 0x00000000L), HEXCONSTE(-3.0, 0xc000, 0xc0000000L, 0x00000000L), FLAG_INEXACT|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* fails with FPU + with gcc 8.3 */
	{ __LINE__, HEXCONSTE(0.9921875L, 0x3ffe, 0xfe000000L, 0x00000000L), HEXCONSTE(0.997389022060725270579075195353955217L, 0x3ffe, 0xff54e30fL, 0x23e69be4L), FLAG_INEXACT|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* fails with FPU + with gcc 8.3 */
	{ __LINE__, HEXCONSTE(0.75L, 0x3ffe, 0xc0000000L, 0x00000000L), HEXCONSTE(0.908560296416069829445605878163630251L, 0x3ffe, 0xe8976857L, 0x8d13f79fL), FLAG_INEXACT|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_ARANYM|FLAG_XFAIL }, /* fails with FPU + with gcc 8.3 */
};

int main(int argc, char **argv)
{
	int status;
	
	status = 0;
	
	test_init(argc, argv);
	
	status |= test_table_f_f(cbrt_data, ARRAY_SIZE(cbrt_data), __FILE__);
	
	return status ? EXIT_FAILURE : EXIT_SUCCESS;
}
