Merge #1229: fix wrong units in remaining time warning
c70a5cb9fe3c3cc60cbfa5383ce669758627684f fix wrong units in remaining time warning (edouardparis) Pull request description: close #1226 ACKs for top commit: edouardparis: Self-ACK c70a5cb9fe3c3cc60cbfa5383ce669758627684f Tree-SHA512: 830772cd3d33ba6809d1a9832f411191812ee52b8c9b43cf280450995c7cf5d423aae2b1c7ee4483da2eccbd6ca3ff7b36a0b5ce26ed4081354d4fe90af69505
This commit is contained in:
commit
39c0458f0b
@ -348,7 +348,7 @@ pub fn expire_message_units(sequence: u32) -> Vec<String> {
|
||||
let n_days = n_minutes / 1440;
|
||||
|
||||
#[allow(clippy::nonminimal_bool)]
|
||||
if n_days != 0 || n_months != 0 || n_days != 0 {
|
||||
if n_years != 0 || n_months != 0 || n_days != 0 {
|
||||
[(n_years, "year"), (n_months, "month"), (n_days, "day")]
|
||||
.iter()
|
||||
.filter_map(|(n, u)| {
|
||||
@ -375,3 +375,20 @@ pub fn expire_message_units(sequence: u32) -> Vec<String> {
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn test_expire_message_units() {
|
||||
let testcases = [
|
||||
(61, vec!["10 hours".to_string(), "10 minutes".to_string()]),
|
||||
(1112, vec!["7 days".to_string()]),
|
||||
(52600, vec!["1 year".to_string()]),
|
||||
];
|
||||
|
||||
for (seq, result) in testcases {
|
||||
assert_eq!(expire_message_units(seq), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user