Skip to content

Commit 1d3132e

Browse files
Add test for fmod
fmod is notoriously buggy. We are going to fix one case in the next commit.
1 parent e7eff1e commit 1d3132e

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

regression/cbmc/fmod1/main.c

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <assert.h>
2+
#include <math.h>
3+
4+
void main()
5+
{
6+
// If x is +-0 and y is not zero, +-0 is returned
7+
assert(fmod(0.0, 1.0) == 0.0);
8+
assert(fmod(-0.0, 1.0) == -0.0);
9+
10+
// If x is +-oo and y is not NaN, NaN is returned and FE_INVALID is raised
11+
assert(isnan(fmod(INFINITY, 1.0)));
12+
assert(isnan(fmod(-INFINITY, 1.0)));
13+
14+
// If y is +-0 and x is not NaN, NaN is returned and FE_INVALID is raised
15+
assert(isnan(fmod(1.0, 0.0)));
16+
assert(isnan(fmod(1.0, -0.0)));
17+
18+
// If y is +-oo and x is finite, x is returned.
19+
assert(fmod(1.0, INFINITY) == 1.0);
20+
assert(fmod(1.0, -INFINITY) == 1.0);
21+
22+
// If either argument is NaN, NaN is returned
23+
assert(isnan(fmod(1.0, NAN)));
24+
assert(isnan(fmod(NAN, 1.0)));
25+
}

regression/cbmc/fmod1/test.desc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
KNOWNBUG
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
Currently, the case where the second argument is +-inf is wrongly
11+
implemented by float_utils.rem.

0 commit comments

Comments
 (0)