Skip to content

Commit

Permalink
add clean to Comparator unit tests and modifications for optionality …
Browse files Browse the repository at this point in the history
…support (and unit tests)

issue #31
  • Loading branch information
Valentin Noel committed Sep 10, 2013
1 parent 689ae35 commit 8cd0511
Show file tree
Hide file tree
Showing 4 changed files with 934 additions and 909 deletions.
32 changes: 22 additions & 10 deletions libraries/comparator/src/Comparator.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,39 @@ void Comparator::checkNode( const sr::SpecNode& node, report_generator::ReportNo
LOG_TRACE( "nextNode: " << nextNode.getId() << " | nodeId: " << nodeId );
rg::ReportNode* nextReportNode;

// check if optional
bool sentToReport = true;

if( node.isOptional() && element->getStatus() != 1 )
{
LOG_TRACE( "Optional & Not Valid -> Go back: " << element->getSize() );
sentToReport = false;
_file->goBack( element->getSize() );
// element->setData( NULL, 0 );
}

// node to report
if( isFirstChild )
if( isFirstChild && sentToReport )
{
rg::ReportNode newReportNode = reportNode.appendChild( element );
nextReportNode = &newReportNode;
}
else
else if( sentToReport )
{
if( node.parent() == NULL )
reportNode = _report->addRootElement( element );
else
reportNode = reportNode.appendNext( element );
nextReportNode = &reportNode;
}
else
{
nextReportNode = &reportNode;
}


// children nodes check
if( node.hasGroup() )
if( node.hasGroup() && sentToReport )
checkNode( node.firstChild(), *nextReportNode, true );

// check repetitions
Expand Down Expand Up @@ -211,11 +227,11 @@ void Comparator::checkNode( const sr::SpecNode& node, report_generator::ReportNo

// next node check
if( ! node.isLastNode() )
checkNode( nextNode, *nextReportNode );
checkNode( nextNode, *nextReportNode, ( isFirstChild && ! sentToReport ) );
else if( nextNode.getId() == nodeId && ! _file->isEndOfFile() && inRange )
checkNode( nextNode, *nextReportNode );
checkNode( nextNode, *nextReportNode, ( isFirstChild && ! sentToReport ) );
else if( _elementIter.at( nodeId ).iter < repetNumber )
checkNode( node, *nextReportNode );
checkNode( node, *nextReportNode, ( isFirstChild && ! sentToReport ) );
else
LOG_TRACE( "\t IS LAST NODE !" );

Expand Down Expand Up @@ -275,10 +291,6 @@ void Comparator::extractRepetition( size_t& repetNumber, Vector< size_t >::Pair&
repetRange.push_back( std::make_pair( repetMin, repetMax ) );
}
}

// LOG_INFO( "REP NUMBER: " << repetNumber );
// for( std::pair< size_t, size_t > range : repetRange )
// LOG_INFO( "REP RANGE: [" << range.first << ", " << range.second << "]" );
}
}

Expand Down
Loading

0 comments on commit 8cd0511

Please sign in to comment.