-# $OpenBSD: Makefile,v 1.15 2019/02/21 16:14:45 bluhm Exp $
+# $OpenBSD: Makefile,v 1.16 2023/08/13 07:02:36 miod Exp $
-SUBDIR+= exp fenv floor fpaccuracy lgamma nextafter msun rint round \
+SUBDIR+= exp fenv floor fpaccuracy lgamma modf msun nextafter rint round \
tgamma toint trivial1
.if defined(REGRESS_FULL) || make(clean) || make(cleandir) || make(obj)
--- /dev/null
+/* $OpenBSD: modf_test.c,v 1.1 2023/08/13 07:02:36 miod Exp $ */
+
+/*
+ * Written by Willemijn Coene. Public domain
+ */
+
+#include <assert.h>
+#include <math.h>
+
+void
+modff_infnan(void)
+{
+ float f, i;
+
+ f = modff(__builtin_inff(), &i);
+ assert(isinf(i));
+ assert(signbit(i) == 0);
+ assert(f == 0.0f);
+
+ f = modff(-__builtin_inff(), &i);
+ assert(isinf(i));
+ assert(signbit(i) != 0);
+ assert(f == -0.0f);
+
+ f = modff(NAN, &i);
+ assert(isnan(i));
+ assert(signbit(i) == 0);
+ assert(isnan(f));
+ assert(signbit(f) == 0);
+
+ f = modff(-NAN, &i);
+ assert(isnan(i));
+ assert(signbit(i) != 0);
+ assert(isnan(f));
+ assert(signbit(f) != 0);
+}
+
+void
+modfl_infnan(void)
+{
+ long double f, i;
+
+ f = modfl(__builtin_infl(), &i);
+ assert(isinf(i));
+ assert(signbit(i) == 0);
+ assert(f == 0.0L);
+
+ f = modfl(-__builtin_infl(), &i);
+ assert(isinf(i));
+ assert(signbit(i) != 0);
+ assert(f == -0.0L);
+
+ f = modfl(NAN, &i);
+ assert(isnan(i));
+ assert(signbit(i) == 0);
+ assert(isnan(f));
+ assert(signbit(f) == 0);
+
+ f = modfl(-NAN, &i);
+ assert(isnan(i));
+ assert(signbit(i) != 0);
+ assert(isnan(f));
+ assert(signbit(f) != 0);
+}
+
+int
+main(void)
+{
+ modff_infnan();
+ modfl_infnan();
+}