-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit and property tests for sampling and type unification #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@@ -18,3 +18,6 @@ serde_json = { version = "1.0.113", features = ["raw_value"] } | |||
thiserror = "1.0.57" | |||
tokio = { version = "1.36.0", features = ["full"] } | |||
these = "2.0.0" | |||
|
|||
[dev-dependencies] | |||
proptest = "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great idea!
prop_oneof![ | ||
Just(BsonScalarType::Double), | ||
Just(BsonScalarType::Decimal), | ||
Just(BsonScalarType::Int), | ||
Just(BsonScalarType::Long), | ||
Just(BsonScalarType::String), | ||
Just(BsonScalarType::Date), | ||
Just(BsonScalarType::Timestamp), | ||
Just(BsonScalarType::BinData), | ||
Just(BsonScalarType::ObjectId), | ||
Just(BsonScalarType::Bool), | ||
Just(BsonScalarType::Null), | ||
Just(BsonScalarType::Regex), | ||
Just(BsonScalarType::Javascript), | ||
Just(BsonScalarType::JavascriptWithScope), | ||
Just(BsonScalarType::MinKey), | ||
Just(BsonScalarType::MaxKey), | ||
Just(BsonScalarType::Undefined), | ||
Just(BsonScalarType::DbPointer), | ||
Just(BsonScalarType::Symbol), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a way to avoid writing out all the enum variants since BsonScalarType
implements enum_iterator::Sequence
. But I don't know how to do that in proptest. Something like,
let n = arb in (0...BsonScalarType.CARDINALITY);
let scalar_type = BsonScalarType::all().nth(n);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into this another time. Wanted to get this merged so we can tag a build to put in the CLI registry.
No description provided.