forked from proxmox-mirrors/proxmox
human-byte: move tests to their sub module
The `#[cfg(test)]` directive ensures that the tests are not compiled for non-test builds. Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
parent
c3545d6644
commit
77dbc2fe18
@ -226,6 +226,10 @@ impl std::str::FromStr for HumanByte {
|
|||||||
proxmox_serde::forward_deserialize_to_from_str!(HumanByte);
|
proxmox_serde::forward_deserialize_to_from_str!(HumanByte);
|
||||||
proxmox_serde::forward_serialize_to_display!(HumanByte);
|
proxmox_serde::forward_serialize_to_display!(HumanByte);
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_human_byte_parser() -> Result<(), Error> {
|
fn test_human_byte_parser() -> Result<(), Error> {
|
||||||
assert!("-10".parse::<HumanByte>().is_err()); // negative size
|
assert!("-10".parse::<HumanByte>().is_err()); // negative size
|
||||||
@ -356,3 +360,4 @@ fn test_human_byte_auto_unit_binary() {
|
|||||||
assert_eq!(convert((1 << 40) + 128 * (1 << 30)), "1.125 TiB");
|
assert_eq!(convert((1 << 40) + 128 * (1 << 30)), "1.125 TiB");
|
||||||
assert_eq!(convert((2 << 50) + 512 * (1 << 40)), "2.5 PiB");
|
assert_eq!(convert((2 << 50) + 512 * (1 << 40)), "2.5 PiB");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user