Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

env:
B2_OPTS: -q -j2 warnings-as-errors=on
GCC_VERSION: 11

jobs:
cov:
Expand Down Expand Up @@ -49,12 +50,12 @@ jobs:
cd libs/histogram

# don't compile examples in coverage build, coverage must come from tests alone
../../b2 $B2_OPTS toolset=gcc-8 cxxstd=latest coverage=on test//all
../../b2 $B2_OPTS toolset=gcc-${GCC_VERSION} cxxstd=latest coverage=on test//all

- name: Process coverage data
run: |
cd libs/histogram
GCOV=gcov-8 tools/cov.py
GCOV=gcov-${GCC_VERSION} tools/cov.py

- uses: coverallsapp/[email protected]
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ jobs:
- name: ctest
run: |
cd build
cmake --build . -j3 --target tests # temporary workaround (I hope)
ctest -C Debug --output-on-failure
4 changes: 2 additions & 2 deletions .github/workflows/slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
cd libs/histogram
../../b2 $B2_OPTS toolset=gcc-10 cxxstd=20 cxxflags="-O3 -funsafe-math-optimizations" test//all examples

clang6:
clang10:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -127,4 +127,4 @@ jobs:
- name: Test cxxstd=17 ubsan asan
run: |
cd libs/histogram
../../b2 $B2_OPTS toolset=clang-6 cxxstd=17 variant=histogram_ubasan test//all
../../b2 $B2_OPTS toolset=clang-10 cxxstd=17 variant=histogram_ubasan test//all
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

include(CTest)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
add_dependencies(check tests) # needed to build the "run" tests

if(BUILD_TESTING)

Expand Down
6 changes: 6 additions & 0 deletions include/boost/histogram/detail/atomic_number.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ struct atomic_number : std::atomic<T> {
return *this;
}

// not thread-safe
atomic_number& operator*=(const T& x) noexcept {
this->store(this->load() * x);
return *this;
}

private:
// for integral types
template <class U = T>
Expand Down
4 changes: 2 additions & 2 deletions include/boost/histogram/histogram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class histogram : detail::mutex_base<Axes, Storage> {
detail::sample_args_passed_vs_expected<sample_args_passed,
typename acc_traits::args>();
std::lock_guard<typename mutex_base::type> guard{mutex_base::get()};
mp11::tuple_apply(
mp11::tuple_apply( // LCOV_EXCL_LINE: gcc-11 is missing this line for no reason
[&](const auto&... sargs) {
constexpr bool sample_valid =
std::is_convertible<sample_args_passed, typename acc_traits::args>::value;
Expand Down Expand Up @@ -309,7 +309,7 @@ class histogram : detail::mutex_base<Axes, Storage> {
detail::sample_args_passed_vs_expected<sample_args_passed,
typename acc_traits::args>();
std::lock_guard<typename mutex_base::type> guard{mutex_base::get()};
mp11::tuple_apply(
mp11::tuple_apply( // LCOV_EXCL_LINE: gcc-11 is missing this line for no reason
[&](const auto&... sargs) {
constexpr bool weight_valid = acc_traits::weight_support;
static_assert(weight_valid, "error: accumulator does not support weights");
Expand Down
50 changes: 30 additions & 20 deletions test/accumulators_count_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,38 @@ template <class T, bool B>
void run_tests() {
using c_t = accumulators::count<T, B>;

c_t c;
++c;
BOOST_TEST_EQ(c.value(), 1);
BOOST_TEST_EQ(str(c), "1"s);
BOOST_TEST_EQ(str(c, 2, false), " 1"s);
BOOST_TEST_EQ(str(c, 2, true), "1 "s);

c += 2;
BOOST_TEST_EQ(str(c), "3"s);

BOOST_TEST_EQ(c, static_cast<T>(3));
BOOST_TEST_NE(c, static_cast<T>(2));

c_t one(1), two(2), one_copy(1);
BOOST_TEST_LT(one, two);
BOOST_TEST_LE(one, two);
BOOST_TEST_LE(one, one_copy);
BOOST_TEST_GT(two, one);
BOOST_TEST_GE(two, one);
BOOST_TEST_GE(one, one_copy);
{
c_t c;
++c;
BOOST_TEST_EQ(c.value(), 1);
BOOST_TEST_EQ(str(c), "1"s);
BOOST_TEST_EQ(str(c, 2, false), " 1"s);
BOOST_TEST_EQ(str(c, 2, true), "1 "s);

c += 2;
BOOST_TEST_EQ(str(c), "3"s);

BOOST_TEST_EQ(c, static_cast<T>(3));
BOOST_TEST_NE(c, static_cast<T>(2));
}

{
c_t one(1), two(2), one_copy(1);
BOOST_TEST_LT(one, two);
BOOST_TEST_LE(one, two);
BOOST_TEST_LE(one, one_copy);
BOOST_TEST_GT(two, one);
BOOST_TEST_GE(two, one);
BOOST_TEST_GE(one, one_copy);
}

BOOST_TEST_EQ(c_t{} += c_t{}, c_t{});

{
c_t two(2);
auto six = two * 3;
BOOST_TEST_EQ(six, static_cast<T>(6));
}
}

int main() {
Expand Down
2 changes: 1 addition & 1 deletion tools/cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

LCOV_VERSION = "1.15"

gcov = os.environ.get("GCOV", "gcov-8")
gcov = os.environ.get("GCOV", "gcov")

gcov_version = gcov.split("-")[1] if "-" in gcov else None
gcc_version = f"gcc-{gcov_version}" if gcov_version else "gcc"
Expand Down