diff --git a/cmake/unit_testing.cmake b/cmake/unit_testing.cmake index 0a03d0b..ae2a8a9 100644 --- a/cmake/unit_testing.cmake +++ b/cmake/unit_testing.cmake @@ -40,6 +40,7 @@ add_subdirectory( src/dryad/TabulatedEnergyDistribution/test ) add_subdirectory( src/dryad/TabulatedEnergyDistributions/test ) add_subdirectory( src/dryad/TwoBodyDistributionData/test ) add_subdirectory( src/dryad/UncorrelatedDistributionData/test ) +add_subdirectory( src/dryad/IncoherentDistributionData/test ) add_subdirectory( src/dryad/ReactionProduct/test ) add_subdirectory( src/dryad/TabulatedCrossSection/test ) diff --git a/src/dryad/IncoherentDistributionData/test/CMakeLists.txt b/src/dryad/IncoherentDistributionData/test/CMakeLists.txt new file mode 100644 index 0000000..0564d3e --- /dev/null +++ b/src/dryad/IncoherentDistributionData/test/CMakeLists.txt @@ -0,0 +1 @@ +add_cpp_test( IncoherentDistributionData IncoherentDistributionData.test.cpp ) diff --git a/src/dryad/IncoherentDistributionData/test/IncoherentDistributionData.test.cpp b/src/dryad/IncoherentDistributionData/test/IncoherentDistributionData.test.cpp new file mode 100644 index 0000000..f82e11c --- /dev/null +++ b/src/dryad/IncoherentDistributionData/test/IncoherentDistributionData.test.cpp @@ -0,0 +1,53 @@ +// include Catch2 +#include +#include +using Catch::Matchers::WithinRel; + +// what we are testing +#include "dryad/IncoherentDistributionData.hpp" + +// other includes + +// convenience typedefs +using namespace njoy::dryad; + +void verifyChunk( const IncoherentDistributionData& ); + +SCENARIO( "IncoherentDistributionData" ) { + + GIVEN( "valid data for incoherent distribution data" ) { + + WHEN( "the data is given explicitly" ) { + + ReferenceFrame frame = ReferenceFrame::CentreOfMass; + TabulatedScatteringFunction scattering( { 1., 2e+7 }, { 2., 1. } ); + + IncoherentDistributionData chunk( std::move( frame ), std::move( scattering ) ); + + THEN( "a Reaction can be constructed and members can be tested" ) { + + verifyChunk( chunk ); + } // THEN + } // WHEN + } // GIVEN +} // SCENARIO + +void verifyChunk( const IncoherentDistributionData& chunk ) { + + CHECK( DistributionDataType::Incoherent == chunk.type() ); + CHECK( ReferenceFrame::CentreOfMass == chunk.frame() ); + + CHECK_THAT( 1. , WithinRel( chunk.scatteringFunction().lowerInverseLengthLimit() ) ); + CHECK_THAT( 2e+7, WithinRel( chunk.scatteringFunction().upperInverseLengthLimit() ) ); + CHECK( 2 == chunk.scatteringFunction().inverseLengths().size() ); + CHECK( 2 == chunk.scatteringFunction().values().size() ); + CHECK( 1 == chunk.scatteringFunction().boundaries().size() ); + CHECK( 1 == chunk.scatteringFunction().interpolants().size() ); + CHECK_THAT( 1. , WithinRel( chunk.scatteringFunction().inverseLengths()[0] ) ); + CHECK_THAT( 2e+7, WithinRel( chunk.scatteringFunction().inverseLengths()[1] ) ); + CHECK_THAT( 2., WithinRel( chunk.scatteringFunction().values()[0] ) ); + CHECK_THAT( 1., WithinRel( chunk.scatteringFunction().values()[1] ) ); + CHECK( 1 == chunk.scatteringFunction().boundaries()[0] ); + CHECK( InterpolationType::LinearLinear == chunk.scatteringFunction().interpolants()[0] ); + CHECK( true == chunk.scatteringFunction().isLinearised() ); +} diff --git a/src/dryad/TabulatedScatteringFunction/test/TabulatedScatteringFunction.test.cpp b/src/dryad/TabulatedScatteringFunction/test/TabulatedScatteringFunction.test.cpp index 2958cfa..f0f86e0 100644 --- a/src/dryad/TabulatedScatteringFunction/test/TabulatedScatteringFunction.test.cpp +++ b/src/dryad/TabulatedScatteringFunction/test/TabulatedScatteringFunction.test.cpp @@ -17,10 +17,10 @@ SCENARIO( "TabulatedScatteringFunction" ) { WHEN( "the data is given explicitly" ) { - const std::vector< double > energies = { 1., 2., 3., 4. }; + const std::vector< double > x = { 1., 2., 3., 4. }; const std::vector< double > values = { 4., 3., 2., 1. }; - TabulatedScatteringFunction chunk( std::move( energies ), std::move( values ) ); + TabulatedScatteringFunction chunk( std::move( x ), std::move( values ) ); THEN( "a TabulatedScatteringFunction can be constructed and members can be tested" ) { @@ -621,11 +621,11 @@ SCENARIO( "TabulatedScatteringFunction" ) { WHEN( "the data is given explicitly" ) { - const std::vector< double > energies = { 1., 2., 2., 3., 4. }; + const std::vector< double > x = { 1., 2., 2., 3., 4. }; const std::vector< double > values = { 4., 3., 4., 3., 2. }; InterpolationType interpolant = InterpolationType::LinearLinear; - TabulatedScatteringFunction chunk( std::move( energies ), std::move( values ), + TabulatedScatteringFunction chunk( std::move( x ), std::move( values ), interpolant ); THEN( "a TabulatedScatteringFunction can be constructed and members can be tested" ) { @@ -1289,7 +1289,7 @@ SCENARIO( "TabulatedScatteringFunction" ) { WHEN( "the data is given explicitly" ) { - const std::vector< double > energies = { 1., 2., 3., 4. }; + const std::vector< double > x = { 1., 2., 3., 4. }; const std::vector< double > values = { 4., 3., 2., 1. }; const std::vector< std::size_t > boundaries = { 1, 3 }; const std::vector< InterpolationType > interpolants = { @@ -1298,7 +1298,7 @@ SCENARIO( "TabulatedScatteringFunction" ) { InterpolationType::LinearLog }; - TabulatedScatteringFunction chunk( std::move( energies ), + TabulatedScatteringFunction chunk( std::move( x ), std::move( values ), std::move( boundaries ), std::move( interpolants ) ); @@ -1437,7 +1437,7 @@ SCENARIO( "TabulatedScatteringFunction" ) { WHEN( "the data is given explicitly" ) { - const std::vector< double > energies = { 1., 2., 2., 3., 4. }; + const std::vector< double > x = { 1., 2., 2., 3., 4. }; const std::vector< double > values = { 4., 3., 4., 3., 2. }; const std::vector< std::size_t > boundaries = { 1, 4 }; const std::vector< InterpolationType > interpolants = { @@ -1446,7 +1446,7 @@ SCENARIO( "TabulatedScatteringFunction" ) { InterpolationType::LinearLog }; - TabulatedScatteringFunction chunk( std::move( energies ), + TabulatedScatteringFunction chunk( std::move( x ), std::move( values ), std::move( boundaries ), std::move( interpolants ) );