You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is an adaptation of the code shown in the documentation, which illustrates the problem
mod foo {use float_eq::*;#[derive_float_eq( ulps_tol = "PointUlps", ulps_tol_derive = "Clone, Copy, Debug, PartialEq", debug_ulps_diff = "PointUlpsDebugUlpsDiff", debug_ulps_diff_derive = "Clone, Copy, Debug, PartialEq", all_tol = "f64")]#[derive(Debug,PartialEq,Clone,Copy)]pubstructPoint{pubx:f64,puby:f64,}#[cfg(test)]#[test]fntest_same_module(){let a = Point{x:1.0,y: -2.0};let c = Point{x:1.000_000_000_000_000_9,y: -2.000_000_000_000_001_3};assert_float_eq!(a, c, ulps <= PointUlps{ x: 4, y: 3});// Worksassert_float_eq!(a, c, ulps_all <= 4);}}#[cfg(test)]mod tests {usesuper::foo::*;use float_eq::assert_float_eq;#[test]fntest_other_module(){let a = Point{x:1.0,y: -2.0};let c = Point{x:1.000_000_000_000_000_9,y: -2.000_000_000_000_001_3};assert_float_eq!(a, c, ulps <= PointUlps{ x: 4, y: 3});// ERROR: x and y privateassert_float_eq!(a, c, ulps_all <= 4);}}
Both foo::Point and its x and y fields are public, so they can be used in other modules. However, the x and y fields of the derived PointUlps are private, preventing them from being used in other modules, which makes the whole of PointUlps unusable.
The text was updated successfully, but these errors were encountered:
Going off on a tangent (let me know if there's a better place to raise this) ... I have a struct with a bunch of (lots, too many!) fields, and one or two of them are expected to be NaNs. I would like to be able to express a test along the lines of
Each of these fields should match within ulps <= 1 (or specific different ulpses for each) except these two which should be NaNs.
Is there any way of doing without writing a separate assertion for each member?
Here is an adaptation of the code shown in the documentation, which illustrates the problem
Both
foo::Point
and itsx
andy
fields are public, so they can be used in other modules. However, thex
andy
fields of the derivedPointUlps
are private, preventing them from being used in other modules, which makes the whole ofPointUlps
unusable.The text was updated successfully, but these errors were encountered: