Skip to content

Commit

Permalink
Adding some more methods
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Apr 18, 2024
1 parent 23b34a9 commit 6a2ea64
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/NDItk/MultigroupTable/test/MultigroupTable.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand All @@ -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] ) );
}
13 changes: 13 additions & 0 deletions src/NDItk/multigroup/Structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/NDItk/multigroup/Structure/test/Structure.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] ) );
}

0 comments on commit 6a2ea64

Please sign in to comment.