diff --git a/src/NDItk/MultigroupTable/test/MultigroupTable.test.cpp b/src/NDItk/MultigroupTable/test/MultigroupTable.test.cpp index eb69143..40ac115 100644 --- a/src/NDItk/MultigroupTable/test/MultigroupTable.test.cpp +++ b/src/NDItk/MultigroupTable/test/MultigroupTable.test.cpp @@ -80,6 +80,7 @@ std::string chunk() { void verifyChunk( const MultigroupTable& chunk ) { + // metadata CHECK( "92235.711nm" == chunk.metadata().zaid().value() ); CHECK( "mendf71x" == chunk.metadata().libraryName().value() ); CHECK( "12/22/2011" == chunk.metadata().sourceData().value() ); @@ -92,4 +93,18 @@ void verifyChunk( const MultigroupTable& chunk ) { CHECK( 6 == chunk.metadata().numberDownscatterGroups().value() ); CHECK( 0 == chunk.metadata().numberUpscatterGroups().value() ); CHECK( 5 == chunk.metadata().legendreOrder().value() ); + + // principal group structure + CHECK( "e_bounds" == chunk.structure().keyword() ); + CHECK( true == chunk.structure().hasContent() ); + CHECK( 8 == chunk.structure().boundaries().value().size() ); + CHECK( 7 == chunk.structure().numberGroups() ); + CHECK_THAT( 20, WithinRel( chunk.structure().boundaries().value()[0] ) ); + CHECK_THAT( 18, WithinRel( chunk.structure().boundaries().value()[1] ) ); + CHECK_THAT( 16, WithinRel( chunk.structure().boundaries().value()[2] ) ); + CHECK_THAT( 14, WithinRel( chunk.structure().boundaries().value()[3] ) ); + CHECK_THAT( 10, WithinRel( chunk.structure().boundaries().value()[4] ) ); + CHECK_THAT( 5, WithinRel( chunk.structure().boundaries().value()[5] ) ); + CHECK_THAT( 1, WithinRel( chunk.structure().boundaries().value()[6] ) ); + CHECK_THAT( 1e-11, WithinRel( chunk.structure().boundaries().value()[7] ) ); } diff --git a/src/NDItk/multigroup/Structure.hpp b/src/NDItk/multigroup/Structure.hpp index 209519b..a8fe373 100644 --- a/src/NDItk/multigroup/Structure.hpp +++ b/src/NDItk/multigroup/Structure.hpp @@ -32,6 +32,19 @@ class Structure : protected base::RealListRecord { using base::RealListRecord::keyword; decltype(auto) boundaries() const { return this->content(); } + + std::size_t numberGroups() const { + + if ( this->hasContent() ) { + + return this->boundaries().value().size() - 1; + } + else { + + return 0; + } + } + using base::RealListRecord::hasContent; using base::RealListRecord::read; diff --git a/src/NDItk/multigroup/Structure/test/Structure.test.cpp b/src/NDItk/multigroup/Structure/test/Structure.test.cpp index 1613d3c..2ac1797 100644 --- a/src/NDItk/multigroup/Structure/test/Structure.test.cpp +++ b/src/NDItk/multigroup/Structure/test/Structure.test.cpp @@ -79,5 +79,15 @@ std::string chunk() { void verifyChunk( const Structure& chunk ) { CHECK( "e_bounds" == chunk.keyword() ); + CHECK( true == chunk.hasContent() ); CHECK( 8 == chunk.boundaries().value().size() ); + CHECK( 7 == chunk.numberGroups() ); + CHECK_THAT( 20, WithinRel( chunk.boundaries().value()[0] ) ); + CHECK_THAT( 18, WithinRel( chunk.boundaries().value()[1] ) ); + CHECK_THAT( 16, WithinRel( chunk.boundaries().value()[2] ) ); + CHECK_THAT( 14, WithinRel( chunk.boundaries().value()[3] ) ); + CHECK_THAT( 10, WithinRel( chunk.boundaries().value()[4] ) ); + CHECK_THAT( 5, WithinRel( chunk.boundaries().value()[5] ) ); + CHECK_THAT( 1, WithinRel( chunk.boundaries().value()[6] ) ); + CHECK_THAT( 1e-11, WithinRel( chunk.boundaries().value()[7] ) ); }