mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-11 06:59:54 +00:00
[clippy]: api-test: fix unsuffixed memory values
Clippy actually noticed that the else branch was the same as the one for the 'b' suffix... Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
27f954f632
commit
4a33af4387
@ -37,12 +37,25 @@ impl std::str::FromStr for Memory {
|
||||
} else if s.ends_with('b') || s.ends_with('B') {
|
||||
Ok(Self::from_bytes(s[..s.len() - 1].parse()?))
|
||||
} else {
|
||||
Ok(Self::from_bytes(s[..s.len() - 1].parse()?))
|
||||
Ok(Self::from_bytes(s.parse()?))
|
||||
}
|
||||
}
|
||||
}
|
||||
proxmox::api::derive_parse_cli_from_str!(Memory);
|
||||
|
||||
#[test]
|
||||
fn test_suffixes() {
|
||||
use std::str::FromStr;
|
||||
assert_eq!(
|
||||
Memory::from_str("1234b").unwrap(),
|
||||
Memory::from_str("1234").unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
Memory::from_str("4096K").unwrap(),
|
||||
Memory::from_str("4M").unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Memory {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
const SUFFIXES: &'static [&'static str] = &["b", "KiB", "MiB", "GiB", "TiB"];
|
||||
|
Loading…
Reference in New Issue
Block a user