From d5e98f40854c30b36c995654dcf38770f5fb2eb9 Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Tue, 6 Apr 2021 17:29:58 +0200 Subject: [PATCH] style --- .../process/BoundaryCrossingProcess.hpp | 10 ++--- .../framework/process/ContinuousProcess.hpp | 17 ++++---- .../detail/framework/process/DecayProcess.hpp | 18 ++++---- .../framework/process/InteractionProcess.hpp | 21 +++++----- .../framework/process/SecondariesProcess.hpp | 8 ++-- .../detail/framework/process/StackProcess.hpp | 8 ++-- tests/framework/testProcessSequence.cpp | 42 ++++++++++--------- 7 files changed, 62 insertions(+), 62 deletions(-) diff --git a/corsika/detail/framework/process/BoundaryCrossingProcess.hpp b/corsika/detail/framework/process/BoundaryCrossingProcess.hpp index 1e9f7b869..1efd36454 100644 --- a/corsika/detail/framework/process/BoundaryCrossingProcess.hpp +++ b/corsika/detail/framework/process/BoundaryCrossingProcess.hpp @@ -40,10 +40,10 @@ namespace corsika { static decltype(testSignature(&T::doBoundaryCrossing)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} @@ -51,7 +51,7 @@ namespace corsika { //! @file BoundaryCrossingProcess.hpp //! value traits type - + template <class TProcess, typename TReturn, typename TParticle> bool constexpr has_method_doBoundaryCrossing_v = has_method_doBoundaryCrossing<TProcess, TReturn, TParticle>::value; diff --git a/corsika/detail/framework/process/ContinuousProcess.hpp b/corsika/detail/framework/process/ContinuousProcess.hpp index 6827ac3c9..451f45a68 100644 --- a/corsika/detail/framework/process/ContinuousProcess.hpp +++ b/corsika/detail/framework/process/ContinuousProcess.hpp @@ -36,10 +36,10 @@ namespace corsika { static decltype(testSignature(&T::doContinuous)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} @@ -51,7 +51,6 @@ namespace corsika { bool constexpr has_method_doContinuous_v = has_method_doContinuous<TProcess, TReturn, TArg1, TArg2>::value; - /** traits test for ContinuousProcess::getMaxStepLength method */ @@ -77,10 +76,10 @@ namespace corsika { static decltype(testSignature(&T::getMaxStepLength)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} diff --git a/corsika/detail/framework/process/DecayProcess.hpp b/corsika/detail/framework/process/DecayProcess.hpp index 35bf56e77..b5664418a 100644 --- a/corsika/detail/framework/process/DecayProcess.hpp +++ b/corsika/detail/framework/process/DecayProcess.hpp @@ -38,10 +38,10 @@ namespace corsika { static decltype(testSignature(&T::doDecay)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<process_type>(nullptr)); static const bool value = type::value; //! @} @@ -67,7 +67,7 @@ namespace corsika { template <class T> static std::false_type test(...); - //! signature of templated method + //! signature of templated method template <class T> static decltype(testSignature(&T::template getLifetime<TArgs...>)) test( std::nullptr_t); @@ -77,10 +77,10 @@ namespace corsika { static decltype(testSignature(&T::getLifetime)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} diff --git a/corsika/detail/framework/process/InteractionProcess.hpp b/corsika/detail/framework/process/InteractionProcess.hpp index 1de29c1f8..8fb157a68 100644 --- a/corsika/detail/framework/process/InteractionProcess.hpp +++ b/corsika/detail/framework/process/InteractionProcess.hpp @@ -36,10 +36,10 @@ namespace corsika { static decltype(testSignature(&T::doInteraction)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} @@ -51,7 +51,6 @@ namespace corsika { bool constexpr has_method_doInteract_v = has_method_doInteract<TProcess, TReturn, TArgs...>::value; - /** traits test for InteractionProcess::getInteractionLength method */ @@ -77,10 +76,10 @@ namespace corsika { static decltype(testSignature(&T::getInteractionLength)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} @@ -88,9 +87,9 @@ namespace corsika { //! @file BoundaryCrossingProcess.hpp //! value traits type - + template <class TProcess, typename TReturn, typename... TArgs> bool constexpr has_method_getInteractionLength_v = has_method_getInteractionLength<TProcess, TReturn, TArgs...>::value; - + } // namespace corsika diff --git a/corsika/detail/framework/process/SecondariesProcess.hpp b/corsika/detail/framework/process/SecondariesProcess.hpp index 4a1d42e61..0310bf3df 100644 --- a/corsika/detail/framework/process/SecondariesProcess.hpp +++ b/corsika/detail/framework/process/SecondariesProcess.hpp @@ -36,10 +36,10 @@ namespace corsika { static decltype(testSignature(&T::doSecondaries)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} diff --git a/corsika/detail/framework/process/StackProcess.hpp b/corsika/detail/framework/process/StackProcess.hpp index 4222c4f96..68f350adf 100644 --- a/corsika/detail/framework/process/StackProcess.hpp +++ b/corsika/detail/framework/process/StackProcess.hpp @@ -39,10 +39,10 @@ namespace corsika { static decltype(testSignature(&T::doStack)) test(std::nullptr_t); public: - /** - @name traits results - @{ - */ + /** + @name traits results + @{ + */ using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; //! @} diff --git a/tests/framework/testProcessSequence.cpp b/tests/framework/testProcessSequence.cpp index 58be1f358..85c050645 100644 --- a/tests/framework/testProcessSequence.cpp +++ b/tests/framework/testProcessSequence.cpp @@ -21,7 +21,6 @@ #include <boost/type_index.hpp> - /* Unit test for testing all Process types and their arrangement in containers ProcessSequence and SwitchProcessSequence @@ -34,7 +33,8 @@ static int const nData = 10; // DummyNode is only needed for BoundaryCrossingProcess struct DummyNode { - DummyNode(int v) : data_(v) {} + DummyNode(int v) + : data_(v) {} int data_ = 0; }; @@ -59,7 +59,6 @@ struct DummyView { DummyData& parent() { return p_; } }; - int globalCount = 0; // simple counter int checkDecay = 0; // use this as a bit field @@ -334,20 +333,21 @@ private: class Boundary1 : public BoundaryCrossingProcess<Boundary1> { public: - Boundary1(double const v=1.0) : v_(v) {} - + Boundary1(double const v = 1.0) + : v_(v) {} + template <typename Particle> ProcessReturn doBoundaryCrossing(Particle& p, typename Particle::node_type const& from, typename Particle::node_type const& to) { - for (int i = 0; i < nData; ++i) { p.data_[i] += v_*(from.data_ - to.data_); } + for (int i = 0; i < nData; ++i) { p.data_[i] += v_ * (from.data_ - to.data_); } return ProcessReturn::Ok; } + private: double v_ = 0.0; }; - TEST_CASE("ProcessSequence General", "ProcessSequence") { logging::set_level(logging::level::info); @@ -537,9 +537,11 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") { DummyData particle; DummyNode node_from(5); DummyNode node_to(4); - + int const nLoop = 20; - for (int i = 0; i < nLoop; ++i) { sequence1.doBoundaryCrossing(particle, node_from, node_to); } + for (int i = 0; i < nLoop; ++i) { + sequence1.doBoundaryCrossing(particle, node_from, node_to); + } for (int i = 0; i < nData; i++) { CORSIKA_LOG_DEBUG("data_[{}]={}", i, particle.data_[i]); @@ -550,7 +552,6 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") { CHECK(contains_stack_process_v<decltype(sequence1)> == false); CHECK(count_processes<decltype(sequence1)>::count == 1); } - } TEST_CASE("SwitchProcessSequence", "ProcessSequence") { @@ -581,15 +582,17 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") { auto sequence3 = make_sequence(cp1, Process3(0), SwitchProcessSequence(sequence1, sequence2, select1)); - auto sequence4 = make_sequence(cp1, Boundary1(2.0), Process3(0), - SwitchProcessSequence(sequence1, Boundary1(-1.0), select1)); + auto sequence4 = + make_sequence(cp1, Boundary1(2.0), Process3(0), + SwitchProcessSequence(sequence1, Boundary1(-1.0), select1)); SECTION("Check construction") { - auto sequence_alt = - make_sequence(cp1, Process3(0), - make_select(make_sequence(Process1(0), cp2, Decay1(0), Boundary1(1.0)), - make_sequence(cp3, Process2(0), Boundary1(-1.0), Decay2(0)), select1)); + auto sequence_alt = make_sequence( + cp1, Process3(0), + make_select(make_sequence(Process1(0), cp2, Decay1(0), Boundary1(1.0)), + make_sequence(cp3, Process2(0), Boundary1(-1.0), Decay2(0)), + select1)); auto switch_seq = SwitchProcessSequence(sequence1, sequence2, select1); CHECK(is_process_sequence_v<decltype(switch_seq)>); @@ -699,10 +702,10 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") { sequence4.selectDecay(view, time_select); sequence4.doSecondaries(view); CHECK(checkInteract == 0); - CHECK(checkDecay == 0); + CHECK(checkDecay == 0); CHECK(checkCont == 0); CHECK(checkSec == 0); - + // check that large "select" value will correctly ignore the call lambda_select = 1e5 * square(1_cm) / 1_g; time_select = 1e5 / second; @@ -815,14 +818,13 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") { sequence4.doBoundaryCrossing(particle, node_from, node_to); CHECK(particle.data_[0] == 97); // 100 - 2*1 - 1*1 - + particle.data_[0] = -100; // data positive, selects particular branch on SwitchProcessSequence sequence4.doBoundaryCrossing(particle, node_from, node_to); CHECK(particle.data_[0] == -101); // -100 - 2*1 + 1*1 } - } TEST_CASE("ProcessSequence Indexing", "ProcessSequence") { -- GitLab