Skip to content

Commit 35c7e2a

Browse files
committed
Merge branch '18-build-add-code-coverage-report' into staging
2 parents b4f0eb3 + 0b4054e commit 35c7e2a

4 files changed

Lines changed: 68 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,61 @@ jobs:
308308
with:
309309
github_token: ${{ secrets.GITHUB_TOKEN }}
310310
publish_dir: ./${{ steps.badge_dir.outputs.dir }}
311-
destination_dir: ${{ steps.badge_dir.outputs.dir }}
311+
destination_dir: ${{ steps.badge_dir.outputs.dir }}
312+
313+
coverage:
314+
name: coverage / ubuntu-24.04 / gcc-14
315+
runs-on: ubuntu-24.04
316+
needs: build
317+
318+
env:
319+
CC: gcc-14
320+
CXX: g++-14
321+
GCOV: gcov-14
322+
323+
steps:
324+
- name: Checkout
325+
uses: actions/checkout@v5
326+
with:
327+
fetch-depth: 0
328+
329+
- name: Install dependencies
330+
shell: bash
331+
run: |
332+
sudo apt-get update
333+
sudo apt-get install -y \
334+
cmake \
335+
ninja-build \
336+
gcc-14 \
337+
g++-14 \
338+
lcov
339+
340+
- name: Configure
341+
shell: bash
342+
run: |
343+
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_FLAGS="--coverage -O0 -g" -DCMAKE_CXX_FLAGS="--coverage -O0 -g"
344+
345+
- name: Build
346+
shell: bash
347+
run: |
348+
cmake --build build --parallel
349+
350+
- name: Test
351+
shell: bash
352+
run: |
353+
ctest --test-dir build --output-on-failure --parallel
354+
355+
- name: Capture coverage
356+
shell: bash
357+
run: |
358+
lcov --gcov-tool /usr/bin/gcov-14 --rc geninfo_unexecuted_blocks=1 --directory build --capture --output-file coverage.info
359+
lcov --gcov-tool /usr/bin/gcov-14 --remove coverage.info '/usr/*' '*/test/*' '*/thirdparty/*' --ignore-errors unused --output-file coverage.info
360+
lcov --gcov-tool /usr/bin/gcov-14 --list coverage.info
361+
362+
- name: Upload coverage reports to Codecov
363+
uses: codecov/codecov-action@v5
364+
with:
365+
files: coverage.info
366+
fail_ci_if_error: true
367+
env:
368+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
[![CI](https://github.com/vargalabs/libdecimal/actions/workflows/ci.yml/badge.svg)](https://github.com/vargalabs/libdecimal/actions/workflows/ci.yml)
3-
[![codecov](https://codecov.io/gh/vargalabs/libdecimal/branch/main/graph/badge.svg)](https://codecov.io/gh/vargalabs/libdecimal)
3+
[![codecov](https://codecov.io/gh/vargalabs/libdecimal/graph/badge.svg?token=F6YCNG3HEY)](https://codecov.io/gh/vargalabs/libdecimal)
44
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
55
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.19323619.svg)](https://doi.org/10.5281/zenodo.19323619)
66
[![GitHub release](https://img.shields.io/github/v/release/vargalabs/libdecimal.svg)](https://github.com/vargalabs/libdecimal/releases)
@@ -83,6 +83,12 @@ add_executable(app main.cpp)
8383
target_link_libraries(app PRIVATE libdecimal::libdecimal)
8484
```
8585

86+
## Attribution
87+
**LIBDECIMAL** builds on Intel’s LIBBID implementation of IEEE 754 decimal arithmetic. **The heavy lifting** — the arithmetic itself — comes from the work **of Marius Cornea, John Harrison, Cristina Anderson, and Evgeny Gvozdev**. **The** underlying **model** traces back **to Mike Cowlishaw** and the IEEE 754 standard.
88+
89+
**The template/macro contraption** that makes it usable in modern C++, **along with the full decomposition of BID into sign, significand, and exponent** — that **is on me**.
90+
91+
8692
[200]: https://vargalabs.github.io/libdecimal/badges/ubuntu-22.04-gcc-13.svg
8793
[201]: https://vargalabs.github.io/libdecimal/badges/ubuntu-22.04-gcc-14.svg
8894
[202]: https://vargalabs.github.io/libdecimal/badges/ubuntu-22.04-gcc-15.svg

test/float-conversion.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ namespace test {
2424

2525
template <class float_t>
2626
bool nearly_equal(float_t a, float_t b, float_t eps = static_cast<float_t>(1e-12)) {
27-
if constexpr (std::is_same_v<float_t, long double>)
28-
return std::fabsl(a - b) <= eps;
29-
else
30-
return std::fabs(a - b) <= eps;
27+
return std::fabs(a - b) <= eps;
3128
}
3229
}
3330

test/ops-transcendental.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ TEST_SUITE("transcendental functions::decimal64") {
8888

8989
TEST_CASE("exp at easy points") {
9090
CHECK(test::as_long_double(math::exp(test::dec64_t{"0"})) == doctest::Approx(1.0L));
91-
CHECK(test::as_long_double(math::exp(test::dec64_t{"1"})) == doctest::Approx(std::expl(1.0L)));
91+
CHECK(test::as_long_double(math::exp(test::dec64_t{"1"})) == doctest::Approx(std::exp(1.0L)));
9292
}
9393

9494
TEST_CASE("log at easy points") {
@@ -140,7 +140,7 @@ TEST_SUITE("transcendental functions::decimal128") {
140140

141141
TEST_CASE("exp at easy points") {
142142
CHECK(test::as_long_double(math::exp(test::dec128_t{"0"})) == doctest::Approx(1.0L));
143-
CHECK(test::as_long_double(math::exp(test::dec128_t{"1"})) == doctest::Approx(std::expl(1.0L)));
143+
CHECK(test::as_long_double(math::exp(test::dec128_t{"1"})) == doctest::Approx(std::exp(1.0L)));
144144
}
145145

146146
TEST_CASE("log at easy points") {

0 commit comments

Comments
 (0)