()
| 391 | |
| 392 | #[test] |
| 393 | fn test_f64_snapping() { |
| 394 | let values = [ |
| 395 | // value, tolerance, expected |
| 396 | (0.0, 1.0, 0.0), |
| 397 | (0.4, 1.0, 0.0), |
| 398 | (0.5, 1.0, 1.0), |
| 399 | (1.0, 1.0, 1.0), |
| 400 | (-0.0, 1.0, 0.0), |
| 401 | (-0.4, 1.0, 0.0), |
| 402 | (-0.5, 1.0, -1.0), |
| 403 | (-1.5, 1.0, -2.0), // round away from 0.0 |
| 404 | (-1.0, 1.0, -1.0), |
| 405 | (0.0, 0.5, 0.0), |
| 406 | (0.24, 0.5, 0.0), |
| 407 | (0.25, 0.5, 0.5), |
| 408 | (-0.25, 0.5, -0.5), // round away from 0.0 |
| 409 | (1.4, 0.5, 1.5), |
| 410 | (1.2, 0.5, 1.0), |
| 411 | (-1.4, 0.5, -1.5), |
| 412 | (-1.2, 0.5, -1.0), |
| 413 | ]; |
| 414 | for (value, tolerance, expected) in values { |
| 415 | let actual = snap_f64_grid(value, tolerance); |
| 416 | assert_approx_eq!(f64, actual, expected); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | #[test] |
| 421 | fn test_coord_grid_snapping() { |
nothing calls this directly
no test coverage detected