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
use nalgebra::Unit;
use nalgebra::proptest::vector;
use proptest::prelude::*;
fn arbitrary_unit_vector() -> impl Strategy<Value = Unit<Vector3<f64>>> {
any::<Vector3<f64>>()
.prop_filter("Non-zero vector", |v| v.norm() > 0.5)
.prop_map(|v| Unit::new_normalize(v))
}
Which I then use as follows:
#[test]
fn test_parametric_line_intersection(
intersection_point in arbitrary_point(),
v1 in arbitrary_unit_vector(),
v2 in arbitrary_unit_vector(),
min1 in -10.0 .. 0.0,
max1 in 0.0 .. 10.0,
min2 in -10.0 .. 0.0,
max2 in 0.0 .. 10.0,
)
If we'd like to keep "sensible" inputs, maybe something like this?
/// A Strategy to generate f64 values within the range [-1000.0, 1000.0],
/// though it is set up to be likely to produce zeros, round numbers, and edge cases.
fn scalar_strategy() -> impl Strategy<Value = f64> {
prop_oneof![
prop_oneof![
Just(0.0),
Just(1.0),
Just(-1.0),
Just(1000.0),
Just(-1000.0)
],
-1000.0..1000.0
]
}
(doesn't take away that Unit accepted a 0-norm result, but still)
Hi,
I made the following proptest strategy:
Which I then use as follows:
Resulting in the error:
Note how
v2
has 0 norm, and a negative x-component, despite being wrapped in Unit.The text was updated successfully, but these errors were encountered: