Skip to content

Commit 09c5163

Browse files
committed
more tests
1 parent 50821a8 commit 09c5163

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

core/src/output/number_parts.rs

+22
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,25 @@ impl fmt::Display for NumberParts {
516516
write!(fmt, "{}", self.format("n u w"))
517517
}
518518
}
519+
520+
#[cfg(test)]
521+
mod tests {
522+
use crate::types::{BaseUnit, Number, Numeric};
523+
524+
#[test]
525+
fn test_fmt() {
526+
let number = Number::new_unit(Numeric::from(42), BaseUnit::new("m"));
527+
let ctx = crate::simple_context().unwrap();
528+
let parts = number.to_parts(&ctx);
529+
530+
assert_eq!(parts.format("e"), "42");
531+
assert_eq!(parts.format("a"), "");
532+
assert_eq!(parts.format("u"), "meter");
533+
assert_eq!(parts.format("q"), "length");
534+
assert_eq!(parts.format("w"), "(length)");
535+
assert_eq!(parts.format("d"), "m");
536+
assert_eq!(parts.format("D"), "m");
537+
assert_eq!(parts.format("p"), "(length; m)");
538+
assert_eq!(parts.format("VALUE: e"), "VALUE: 42");
539+
}
540+
}

core/tests/query.rs

+5
Original file line numberDiff line numberDiff line change
@@ -871,3 +871,8 @@ fn conversion_to_digit_errors() {
871871
"Conversion to digits of US/Pacific is not defined",
872872
);
873873
}
874+
875+
#[test]
876+
fn test_conversion_multiples() {
877+
test("floppydisk to 512B", "2880 * 512 byte (information)");
878+
}

0 commit comments

Comments
 (0)