#include "testconfig.h"
#ifdef HAVE_NEXTAFTER
#define TEST_FUNC_FF_F __MATH_PRECNAME(nextafter)
#include "testdriver.h"


static test_ff_f_data const nextafter_data[] = {
	{ __LINE__, ZERO_P, ZERO_P, ZERO_P, NO_INEXACT_EXCEPTION },
	{ __LINE__, ZERO_M, ZERO_P, ZERO_P, NO_INEXACT_EXCEPTION|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_HARDFLOAT },
	{ __LINE__, ZERO_P, ZERO_M, ZERO_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_HARDFLOAT },
	{ __LINE__, ZERO_M, ZERO_M, ZERO_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 },

	{ __LINE__, HEXCONSTE(9, 0x4002, 0x90000000L, 0x00000000L), HEXCONSTE(9, 0x4002, 0x90000000L, 0x00000000L), HEXCONSTE(9, 0x4002, 0x90000000L, 0x00000000L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-9, 0xc002, 0x90000000L, 0x00000000L), HEXCONSTE(-9, 0xc002, 0x90000000L, 0x00000000L), HEXCONSTE(-9, 0xc002, 0x90000000L, 0x00000000L), NO_INEXACT_EXCEPTION },
	{ __LINE__, INF_P, INF_P, INF_P, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 },
	{ __LINE__, INF_M, INF_M, INF_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 },

	{ __LINE__, QNAN_P, HEXCONSTE(1.1L, 0x3fff, 0x8cccccccL, 0xcccccccdL), QNAN_P, NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(1.1L, 0x3fff, 0x8cccccccL, 0xcccccccdL), QNAN_P, QNAN_P, NO_INEXACT_EXCEPTION },
	{ __LINE__, QNAN_P, QNAN_P, QNAN_P, NO_INEXACT_EXCEPTION },

	{ __LINE__, MAX_P, INF_P, INF_P, INEXACT_EXCEPTION|OVERFLOW_EXCEPTION },
	{ __LINE__, MAX_M, INF_M, INF_M, INEXACT_EXCEPTION|OVERFLOW_EXCEPTION },
};

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

#else

int main(void)
{
	return 77;
}

#endif
