diff --git a/.github/workflows/ci-full-test-suite.yml b/.github/workflows/ci-full-test-suite.yml index 1003e3d4..5949ad81 100644 --- a/.github/workflows/ci-full-test-suite.yml +++ b/.github/workflows/ci-full-test-suite.yml @@ -30,7 +30,10 @@ jobs: key: ${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }} - name: Test all crates - run: cargo test --all --verbose --features "use_serde" + run: cargo test --workspace --all-targets --verbose --features "use_serde" + + - name: Test documentation + run: cargo test --workspace --doc --verbose --features "use_serde" - name: Test si run: cargo test --verbose --no-default-features --features "f32 si" diff --git a/.github/workflows/ci-min-test-matrix.yml b/.github/workflows/ci-min-test-matrix.yml index 814cda3a..af224234 100644 --- a/.github/workflows/ci-min-test-matrix.yml +++ b/.github/workflows/ci-min-test-matrix.yml @@ -31,4 +31,4 @@ jobs: toolchain: ${{ matrix.toolchain }} - name: Test all crates - run: cargo test --all --verbose --features "use_serde" + run: cargo test --workspace --verbose --features "use_serde" diff --git a/.github/workflows/ci-tool-checks.yml b/.github/workflows/ci-tool-checks.yml index 1363a52a..9332e467 100644 --- a/.github/workflows/ci-tool-checks.yml +++ b/.github/workflows/ci-tool-checks.yml @@ -39,13 +39,13 @@ jobs: key: tools-${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }} - name: Clippy - run: cargo clippy --all --tests -- -D warnings + run: cargo clippy --workspace --all-targets -- -D warnings - name: Rustfmt run: cargo fmt --all -- --check - name: Rustdoc - run: cargo doc --all --no-deps + run: cargo doc --workspace --lib --bins --examples --no-deps env: RUSTDOCFLAGS: '-D warnings' diff --git a/src/quantity.rs b/src/quantity.rs index c9da83df..8dde0a12 100644 --- a/src/quantity.rs +++ b/src/quantity.rs @@ -137,9 +137,9 @@ macro_rules! quantity { where V: $crate::Conversion, { + test! { /// Check unit validity to ensure the unit is valid for the underlying storage type. - #[cfg(test)] - fn is_valid() -> bool; + fn is_valid() -> bool;} } unit_units! { diff --git a/src/si/time.rs b/src/si/time.rs index 574c6008..b73c99d5 100644 --- a/src/si/time.rs +++ b/src/si/time.rs @@ -173,16 +173,16 @@ mod tests { let s = ((*v).clone() - r.clone()).to_u64(); let n = (r * (V::one() / &ns)).to_u32(); - return match (s, n) { - (Some(s), Some(n)) => TestResult::from_bool( - match (Time::try_from(Duration::new(s, n)), V::from_u64(s), V::from_u32(n)) { - (Ok(t), Some(s), Some(n)) => t == Time::new::(s) + Time::new::(n), - (Err(TryFromError::Overflow), None, _) => true, - (Err(TryFromError::Overflow), _, None) => true, - _ => false, - }), - _ => TestResult::discard(), - } + match (s, n) { + (Some(s), Some(n)) => TestResult::from_bool( + match (Time::try_from(Duration::new(s, n)), V::from_u64(s), V::from_u32(n)) { + (Ok(t), Some(s), Some(n)) => t == Time::new::(s) + Time::new::(n), + (Err(TryFromError::Overflow), None, _) => true, + (Err(TryFromError::Overflow), _, None) => true, + _ => false, + }), + _ => TestResult::discard(), + } } } } diff --git a/src/unit.rs b/src/unit.rs index 3f0f1d1c..e40c3ec1 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -166,7 +166,7 @@ macro_rules! unit_units { } impl super::Conversion for super::$unit { - #[cfg(test)] + test! { #[inline(always)] #[allow(clippy::eq_op)] #[allow(clippy::approx_constant)] @@ -177,7 +177,7 @@ macro_rules! unit_units { let c = >::coefficient().to_f64(); r == c - } + }} })+ } @@ -208,7 +208,7 @@ macro_rules! unit_units { } impl super::Conversion for super::$unit { - #[cfg(test)] + test! { #[inline(always)] #[allow(clippy::eq_op)] #[allow(clippy::approx_constant)] @@ -223,14 +223,14 @@ macro_rules! unit_units { let r = $coefficient; let c = numer / denom; - return r == c + return r == c; } } } } false - } + }} })+ } @@ -266,7 +266,7 @@ macro_rules! unit_units { } impl super::Conversion for super::$unit { - #[cfg(test)] + test! { #[inline(always)] #[allow(clippy::eq_op)] #[allow(clippy::approx_constant)] @@ -280,14 +280,14 @@ macro_rules! unit_units { let r = $coefficient; let c = numer / denom; - return r == c + return r == c; } } } } false - } + }} })+ } @@ -317,7 +317,7 @@ macro_rules! unit_units { } impl super::Conversion for super::$unit { - #[cfg(test)] + test! { #[inline(always)] #[allow(clippy::eq_op)] #[allow(clippy::approx_constant)] @@ -332,14 +332,14 @@ macro_rules! unit_units { let r = $coefficient; let c = numer / denom; - return r == c + return r == c; } } } } false - } + }} })+ } @@ -364,7 +364,7 @@ macro_rules! unit_units { } impl super::Conversion for super::$unit { - #[cfg(test)] + test! { #[inline(always)] #[allow(clippy::eq_op)] #[allow(clippy::approx_constant)] @@ -375,7 +375,7 @@ macro_rules! unit_units { let c = >::coefficient().to_f64(); r == c - } + }} })+ } };