File: allow-larger-rounding-error-on-x86

package info (click to toggle)
rust-vte 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 520 kB
  • sloc: makefile: 8
file content (27 lines) | stat: -rw-r--r-- 1,174 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
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -2442,8 +2442,12 @@
     fn contrast() {
+        #[cfg(target_arch = "x86")]
+        let maxerror = f64::EPSILON * 10.0;
+        #[cfg(not(target_arch = "x86"))]
+        let maxerror = f64::EPSILON;
         let rgb1 = Rgb { r: 0xFF, g: 0xFF, b: 0xFF };
         let rgb2 = Rgb { r: 0x00, g: 0x00, b: 0x00 };
-        assert!((rgb1.contrast(rgb2) - 21.).abs() < f64::EPSILON);
+        assert!((rgb1.contrast(rgb2) - 21.).abs() < maxerror);
 
         let rgb1 = Rgb { r: 0xFF, g: 0xFF, b: 0xFF };
-        assert!((rgb1.contrast(rgb1) - 1.).abs() < f64::EPSILON);
+        assert!((rgb1.contrast(rgb1) - 1.).abs() < maxerror);
 
@@ -2451,3 +2455,3 @@
         let rgb2 = Rgb { r: 0x00, g: 0xFF, b: 0x00 };
-        assert!((rgb1.contrast(rgb2) - 2.285_543_608_124_253_3).abs() < f64::EPSILON);
+        assert!((rgb1.contrast(rgb2) - 2.285_543_608_124_253_3).abs() < maxerror);
 
@@ -2455,3 +2459,3 @@
         let rgb2 = Rgb { r: 0xFE, g: 0xDC, b: 0xBA };
-        assert!((rgb1.contrast(rgb2) - 9.786_558_997_257_74).abs() < f64::EPSILON);
+        assert!((rgb1.contrast(rgb2) - 9.786_558_997_257_74).abs() < maxerror);
     }