Fix Weight::is_zero (#12396)

* Fix Weight::is_zero

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Add test

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2022-10-03 15:17:59 +02:00
committed by GitHub
parent 2a27545afe
commit 8596339b49
+14 -1
View File
@@ -318,7 +318,7 @@ impl Zero for Weight {
}
fn is_zero(&self) -> bool {
self.ref_time == 0
self == &Self::zero()
}
}
@@ -447,3 +447,16 @@ impl SubAssign for Weight {
};
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn is_zero_works() {
assert!(Weight::zero().is_zero());
assert!(!Weight::from_components(1, 0).is_zero());
assert!(!Weight::from_components(0, 1).is_zero());
assert!(!Weight::MAX.is_zero());
}
}