more tests

This commit is contained in:
Tiffany Bennett 2024-06-02 13:50:36 -07:00
parent 50821a845a
commit 09c51634c5
2 changed files with 27 additions and 0 deletions

View file

@ -516,3 +516,25 @@ impl fmt::Display for NumberParts {
write!(fmt, "{}", self.format("n u w"))
}
}
#[cfg(test)]
mod tests {
use crate::types::{BaseUnit, Number, Numeric};
#[test]
fn test_fmt() {
let number = Number::new_unit(Numeric::from(42), BaseUnit::new("m"));
let ctx = crate::simple_context().unwrap();
let parts = number.to_parts(&ctx);
assert_eq!(parts.format("e"), "42");
assert_eq!(parts.format("a"), "");
assert_eq!(parts.format("u"), "meter");
assert_eq!(parts.format("q"), "length");
assert_eq!(parts.format("w"), "(length)");
assert_eq!(parts.format("d"), "m");
assert_eq!(parts.format("D"), "m");
assert_eq!(parts.format("p"), "(length; m)");
assert_eq!(parts.format("VALUE: e"), "VALUE: 42");
}
}

View file

@ -871,3 +871,8 @@ fn conversion_to_digit_errors() {
"Conversion to digits of US/Pacific is not defined",
);
}
#[test]
fn test_conversion_multiples() {
test("floppydisk to 512B", "2880 * 512 byte (information)");
}