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`.
|
/// 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 {
|
struct Default {
|
||||||
a: Amount,
|
a: Amount,
|
||||||
b: SignedAmount,
|
b: SignedAmount,
|
||||||
c: relative::Height,
|
c: BlockInterval,
|
||||||
d: relative::Time,
|
d: relative::Height,
|
||||||
|
e: relative::Time,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A struct that includes all public error types.
|
/// A struct that includes all public error types.
|
||||||
|
@ -249,3 +250,16 @@ fn test_sync() {
|
||||||
assert_sync::<Types>();
|
assert_sync::<Types>();
|
||||||
assert_sync::<Errors>();
|
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