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:
Lukas Wagner 2023-05-08 12:01:36 +02:00 committed by Wolfgang Bumiller
parent c3545d6644
commit 77dbc2fe18

View File

@ -226,6 +226,10 @@ impl std::str::FromStr for HumanByte {
proxmox_serde::forward_deserialize_to_from_str!(HumanByte);
proxmox_serde::forward_serialize_to_display!(HumanByte);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_human_byte_parser() -> Result<(), Error> {
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((2 << 50) + 512 * (1 << 40)), "2.5 PiB");
}
}