diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 31000a274..b8a7f7d79 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,3 +20,14 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + - name: Install cargo-llvm-cov + run: cargo install cargo-llvm-cov + - name: Generate code coverage + run: cargo llvm-cov --all-features --workspace --codecov --output-path codecov.json + - name: Upload coverage to Codecov + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: codecov.json + fail_ci_if_error: true + uses: codecov/codecov-action@v3 + diff --git a/Cargo.toml b/Cargo.toml index 1a8b61451..2efa88a4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,3 +18,6 @@ rust-version = "1.71.1" [dev-dependencies] paste = "1.0.14" +[badges] +codecov = { repository = "nordzilla/count-digits", branch = "main", service = "github" } + diff --git a/README.md b/README.md index 30abee654..34464271b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Coverage Status](https://codecov.io/gh/nordzilla/count-digits/branch/main/graph/badge.svg)](https://codecov.io/gh/nordzilla/count-digits) + # count-digits ## CountDigits diff --git a/src/lib.rs b/src/lib.rs index eee9f769f..95c5ef8cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1040,6 +1040,7 @@ mod count_digits { fn []() { let max = if ($type::MAX as u128) < 1_000_000 { $type::MAX } else { 1_000_000 }; for n in $non_zero_type::MIN.get()..=max { + let n = $non_zero_type::new(n).unwrap(); assert_representations!(n); } }