lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit 0569d7fb97a506f8bc8fa1f29de4f08e73ee617a
parent 0bca749c6404b60216a191ad471e80b2476d35b0
Author: triesap <tyson@radroots.org>
Date:   Sun, 22 Feb 2026 02:40:30 +0000

core: format `radroots-core` crate sources



- run rustfmt for the core crate manifest scope
- normalize multiline assertion and call formatting in core tests
- keep the same core behavior with formatting-only edits
- keep core coverage test paths unchanged after formatting

Diffstat:
Mcrates/core/src/lib.rs | 9+++++++--
Mcrates/core/tests/quantity.rs | 4+++-
Mcrates/core/tests/quantity_price.rs | 21+++++++++++++++++----
3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs @@ -82,8 +82,13 @@ mod ts_export_tests { export_types(); let path = ts_export_dir().join("types.ts"); let raw = fs::read_to_string(path).expect("read generated core types"); - for literal in ["\"each\"", "\"kg\"", "\"g\"", "\"oz\"", "\"lb\"", "\"l\"", "\"ml\""] { - assert!(raw.contains(literal), "missing core unit literal: {literal}"); + for literal in [ + "\"each\"", "\"kg\"", "\"g\"", "\"oz\"", "\"lb\"", "\"l\"", "\"ml\"", + ] { + assert!( + raw.contains(literal), + "missing core unit literal: {literal}" + ); } for literal in ["\"count\"", "\"mass\"", "\"volume\""] { assert!( diff --git a/crates/core/tests/quantity.rs b/crates/core/tests/quantity.rs @@ -172,6 +172,8 @@ fn try_convert_to_rejects_mismatched_dimensions() { #[test] fn try_convert_to_same_unit_returns_self_clone() { let q = common::qty("2", RadrootsCoreUnit::MassG).with_label("x"); - let converted = q.try_convert_to(RadrootsCoreUnit::MassG).expect("same unit"); + let converted = q + .try_convert_to(RadrootsCoreUnit::MassG) + .expect("same unit"); assert_eq!(converted, q); } diff --git a/crates/core/tests/quantity_price.rs b/crates/core/tests/quantity_price.rs @@ -145,7 +145,9 @@ fn try_to_unit_price_error_and_same_unit_paths_are_exercised() { assert_eq!(same.quantity.amount, common::dec("1")); assert_eq!(same.amount.amount, common::dec("2.5")); - let err = base.try_to_unit_price(RadrootsCoreUnit::VolumeMl).unwrap_err(); + let err = base + .try_to_unit_price(RadrootsCoreUnit::VolumeMl) + .unwrap_err(); assert_eq!( err, RadrootsCoreQuantityPriceError::NonConvertibleUnits { @@ -169,7 +171,12 @@ fn cost_for_and_quantized_price_zero_paths_are_exercised() { common::money("3.33", "USD"), common::qty("0", RadrootsCoreUnit::Each), ); - assert!(zero_per.cost_for(&common::qty("1", RadrootsCoreUnit::Each)).amount.is_zero()); + assert!( + zero_per + .cost_for(&common::qty("1", RadrootsCoreUnit::Each)) + .amount + .is_zero() + ); assert!( zero_per .cost_for_with_quantized_price(&common::qty("1", RadrootsCoreUnit::Each)) @@ -178,7 +185,11 @@ fn cost_for_and_quantized_price_zero_paths_are_exercised() { ); let mismatch_qty = common::qty("1", RadrootsCoreUnit::MassG); - assert!(p.cost_for_with_quantized_price(&mismatch_qty).amount.is_zero()); + assert!( + p.cost_for_with_quantized_price(&mismatch_qty) + .amount + .is_zero() + ); } #[test] @@ -187,7 +198,9 @@ fn try_to_unit_price_detects_underflow_to_zero_normalized_amount() { common::money("1", "USD"), common::qty("0.0000000000000000000000000001", RadrootsCoreUnit::VolumeMl), ); - let err = tiny.try_to_unit_price(RadrootsCoreUnit::VolumeL).unwrap_err(); + let err = tiny + .try_to_unit_price(RadrootsCoreUnit::VolumeL) + .unwrap_err(); assert_eq!(err, RadrootsCoreQuantityPriceError::PerQuantityZero); }