Skip to content

Commit

Permalink
modifications in Comparator for status clean support
Browse files Browse the repository at this point in the history
issue #31
  • Loading branch information
Valentin Noel committed Dec 10, 2013
1 parent 9318119 commit d8b636c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
22 changes: 4 additions & 18 deletions libraries/Comparator/src/Comparator/Comparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Comparator::check( spec_reader::Specification& spec, file_reader::FileReade
// LOG_FATAL( node->getId() );
ShPtrElement previous = element;

if( skipElementCheck( previous ) )
if( previous->_status == eStatusSkip )
{
LOG_TRACE( "[comparator] Go back in file (" << size << " bytes)" );
file.goBack( size );
Expand Down Expand Up @@ -106,23 +106,10 @@ bool Comparator::isInUnorderedGroup( const ShPtrElement element )
return false;
}

bool Comparator::skipElementCheck( const ShPtrElement element )
{
switch( element->_status )
{
case eStatusInvalidButOptional :
case eStatusInvalidButSkip :
case eStatusInvalidForIteration :
case eStatusSkip : return true;
default: break;
}
return false;
}

void Comparator::updateParentSize( const ShPtrElement element )
{
ShPtrElement parent = element->getParent();
while( ! skipElementCheck( element ) && parent != nullptr )
while( element->_status != eStatusSkip && parent != nullptr )
{
parent->_childrenSize += element->_data.size();
// LOG_COLOR( common::details::kColorBlue, "[comparator] " << parent->_id << "'s children size : " << parent->_childrenSize << std::endl );
Expand All @@ -133,10 +120,9 @@ void Comparator::updateParentSize( const ShPtrElement element )
Comparator::ShPtrElement Comparator::getNextParent( const ShPtrElement element, const ShPtrSpecNode node )
{
ShPtrElement parent = element->getParent();
bool isLastInGroup = ( node->next() == nullptr && ( parent == nullptr || ( parent->_isOrdered || ( ! parent->_isOrdered && element->_status == eStatusInvalidButSkip ) ) ) );
bool isNotSkipped = ( element->_status != eStatusInvalidButOptional && element->_status != eStatusInvalidButSkip && element->_status != eStatusInvalidForIteration && element->_status != eStatusSkip );
bool isLastInGroup = ( node->next() == nullptr && ( parent == nullptr || ( parent->_isOrdered || ( ! parent->_isOrdered && element->_status == eStatusSkip ) ) ) );

if( element->_isGroup && ! element->_checkedGroup && isNotSkipped )
if( element->_isGroup && ! element->_checkedGroup && element->_status != eStatusSkip )
return element;

if( isLastInGroup && element->getParent() != nullptr )
Expand Down
1 change: 0 additions & 1 deletion libraries/Comparator/src/Comparator/Comparator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class Comparator

private:
bool isInUnorderedGroup( const ShPtrElement element );
bool skipElementCheck ( const ShPtrElement element );
void updateParentSize ( const ShPtrElement element );
ShPtrElement getNextParent ( const ShPtrElement element, const ShPtrSpecNode node );
void checkGroupSize ( const ShPtrElement element, file_reader::FileReader& file );
Expand Down
2 changes: 1 addition & 1 deletion libraries/Comparator/test/comparatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE( comparator_test_comparator_1 )
BOOST_CHECK_EQUAL( report.get( "value12" )->_status, eStatusValid );
BOOST_CHECK_EQUAL( report.get( "value121" )->_status, eStatusValid );
BOOST_CHECK_EQUAL( report.get( "value1211" )->_status, eStatusInvalid );
BOOST_CHECK_EQUAL( report.get( "value1212" )->_status, eStatusPassOver );
BOOST_CHECK_EQUAL( report.get( "value1212" )->_status, eStatusValid );
BOOST_CHECK_EQUAL( report.get( "value122" )->_status, eStatusValid );
BOOST_CHECK_EQUAL( report.get( "value13" )->_status, eStatusValid );
BOOST_CHECK_EQUAL( report.get( "valueEnd" )->_status, eStatusValid );
Expand Down

0 comments on commit d8b636c

Please sign in to comment.