File: relax_test_32bit_float.patch

package info (click to toggle)
msgpuck 2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: ansic: 3,054; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 1,235 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Author: Andreas Tille <tille@debian.org>
Last-Update: 2025-11-17
Description: Make sure test will work on non-amd64 architectures with different float interpretation as well
Forwarded: No, since project is archived

--- a/test/msgpuck.c
+++ b/test/msgpuck.c
@@ -34,6 +34,7 @@
 #include <stdlib.h>
 #include <inttypes.h>
 #include <limits.h>
+#include <math.h>
 
 #include "msgpuck.h"
 #include "test.h"
@@ -995,7 +996,13 @@ test_mp_check()
 	if (_success) {							\
 		is(ret, 0, "%s check success", s);			\
 		is(d1, d2, "%s check pos advanced", s);			\
-		ok(v - _val == 0, "%s check result", s);		\
+                if (sizeof(_type) == sizeof(float)) {                   \
+                    ok(fabsf(v - _val) < 1e-6f, "%s check result", s);  \
+                } else if (sizeof(_type) == sizeof(double)) {           \
+                    ok(fabs(v - _val) < 1e-10, "%s check result", s);   \
+                } else {                                                \
+                    ok(v - _val == 0, "%s check result", s);            \
+                }                                                       \
 	} else {							\
 		is(ret, -1, "%s check fail", s);			\
 		is(d1, data, "%s check pos unchanged", s);		\