units: Add regression tests for Default impls
Add a regression test to the `api` tests to check the value returned by `Default` for all types that implement it.
This commit is contained in:
parent
f5c2248a31
commit
a4a0f2921c
|
@ -98,12 +98,13 @@ struct CommonTraits {
|
|||
}
|
||||
|
||||
/// A struct that includes all types that implement `Default`.
|
||||
#[derive(Default)] // C-COMMON-TRAITS: `Default`
|
||||
#[derive(Debug, Default, PartialEq, Eq)] // C-COMMON-TRAITS: `Default`
|
||||
struct Default {
|
||||
a: Amount,
|
||||
b: SignedAmount,
|
||||
c: relative::Height,
|
||||
d: relative::Time,
|
||||
c: BlockInterval,
|
||||
d: relative::Height,
|
||||
e: relative::Time,
|
||||
}
|
||||
|
||||
/// A struct that includes all public error types.
|
||||
|
@ -249,3 +250,16 @@ fn test_sync() {
|
|||
assert_sync::<Types>();
|
||||
assert_sync::<Errors>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_default() {
|
||||
let got: Default = Default::default();
|
||||
let want = Default {
|
||||
a: Amount::ZERO,
|
||||
b: SignedAmount::ZERO,
|
||||
c: BlockInterval::ZERO,
|
||||
d: relative::Height::ZERO,
|
||||
e: relative::Time::ZERO,
|
||||
};
|
||||
assert_eq!(got, want);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue