Skip to content
Snippets Groups Projects
Commit 8596339b authored by Oliver Tale-Yazdi's avatar Oliver Tale-Yazdi Committed by GitHub
Browse files

Fix `Weight::is_zero` (#12396)


* Fix Weight::is_zero

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

* Add test

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

Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
parent 2a27545a
No related merge requests found
......@@ -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());
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment