Skip to content

Commit

Permalink
modifications in Element and unit tests for status update
Browse files Browse the repository at this point in the history
issue #27
  • Loading branch information
Valentin Noel committed Dec 10, 2013
1 parent 283ff82 commit 607537c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
8 changes: 2 additions & 6 deletions libraries/BasicElement/src/BasicElement/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Element::Element( const ShPtrSpecNode node,
, _type ( node->getType() )
, _displayType ( node->getDisplayType() )
, _iteration ( getElementIteration( _id, _repetExpr, previous, parent ) )
, _status ( eStatusNotChecked )
, _status ( eStatusUnknown )
, _isGroup ( node->isGroup() )
, _isOrdered ( node->isOrdered() )
, _isOptional ( node->isOptional() )
Expand All @@ -51,10 +51,6 @@ Element::Element( const ShPtrSpecNode node,

Element::ShPtrSpecNode Element::next( )
{
// if element has been checked, back to the same SpecNode
if( _status == eStatusNotChecked )
return _specNode;

ShPtrElement parent;
// if parent exists, copy it
if( _parent.use_count() != 0 )
Expand Down Expand Up @@ -132,7 +128,7 @@ size_t Element::getElementIteration( const std::string& id, const ExpressionList
ShPtrElement prev = previous;
while( prev != nullptr || ( parent != nullptr && prev->_id != parent->_id ) )
{
if( prev->_id == id && ( prev->_status == eStatusValid || prev->_status == eStatusPassOver ) )
if( prev->_id == id && ( prev->_status == eStatusValid ) )
{
iteration = prev->_iteration + 1;
break;
Expand Down
50 changes: 28 additions & 22 deletions libraries/BasicElement/src/BasicElement/Element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,31 +136,37 @@ class Element
const bool _isCaseSensitive;
bool _checkedGroup;

static std::string getLabelsLegend()
{
std::stringstream legend;
legend << "========= LEGEND =========" << std::endl;
legend << " v = value " << std::endl;
legend << " t = type " << std::endl;
legend << " i = iteration " << std::endl;
legend << " S = status " << std::endl;
legend << " s = size " << std::endl;
legend << " E = Error " << std::endl;
legend << " W = Warning " << std::endl;
legend << std::endl;
return legend.str();
}

static std::string getElementPropertiesLegend()
{
std::stringstream props;
props << "=== ELEMENT PROPERTIES ===" << std::endl;
props << "B.... = Big endian " << std::endl;
props << "l.... = little endian " << std::endl;
props << ".O... = Optional " << std::endl;
props << "..G.. = Group " << std::endl;
props << "...U. = Unordered " << std::endl;
props << "....R = Repeated " << std::endl;
props << std::endl;
return props.str();
}

};

static std::string getPropertiesLegend()
{
std::stringstream legend;
legend << "========= LEGEND =========" << std::endl;
legend << " v = value " << std::endl;
legend << " t = type " << std::endl;
legend << " i = iteration " << std::endl;
legend << " s = status " << std::endl;
legend << " E = Error " << std::endl;
legend << " W = Warning " << std::endl;
legend << std::endl;
legend << "=== ELEMENT PROPERTIES ===" << std::endl;
legend << "B.... = Big endian " << std::endl;
legend << "l.... = little endian " << std::endl;
legend << ".O... = Optional " << std::endl;
legend << "..G.. = Group " << std::endl;
legend << "...U. = Unordered " << std::endl;
legend << "....R = Repeated " << std::endl;
legend << std::endl;
return legend.str();
}

}

#endif
19 changes: 9 additions & 10 deletions libraries/BasicElement/test/elementTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ BOOST_AUTO_TEST_CASE( basic_element_data_unordered_group )
"content": [
{ "id": "value1",
"label": "Value1",
"type": "ascii",
"ordered": false,
"group": [
{ "id": "value11",
Expand All @@ -340,11 +339,11 @@ BOOST_AUTO_TEST_CASE( basic_element_data_unordered_group )
std::shared_ptr< Element > elem1( new Element( node ) );
BOOST_CHECK_EQUAL( elem1->_id, "value1" );
BOOST_CHECK_EQUAL( elem1->_label, "Value1" );
BOOST_CHECK_EQUAL( elem1->_type, eTypeAscii );
BOOST_CHECK_EQUAL( elem1->_type, eTypeUnknown );
BOOST_CHECK_EQUAL( elem1->_isGroup, true );
BOOST_CHECK_EQUAL( elem1->_isOrdered, false );
BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked );
elem1->_status = eStatusPassOver;
BOOST_CHECK_EQUAL( elem1->_status, eStatusUnknown );
elem1->_status = eStatusUnknown;

std::shared_ptr< Element > elem2( new Element( elem1->next(), elem1, elem1 ) );
BOOST_CHECK_EQUAL( elem2->_id, "value11" );
Expand Down Expand Up @@ -383,7 +382,7 @@ BOOST_AUTO_TEST_CASE( basic_element_data_unordered_group )
elem0->_status = eStatusSkip;

BOOST_CHECK( elem0->next() == nullptr );
BOOST_CHECK_EQUAL( elem1->_status, eStatusPassOver );
BOOST_CHECK_EQUAL( elem1->_status, eStatusUnknown );
}
}

Expand Down Expand Up @@ -414,7 +413,7 @@ BOOST_AUTO_TEST_CASE( basic_element_next_repetition_one )
BOOST_CHECK_EQUAL( elem1->_id, "value1" );
BOOST_CHECK_EQUAL( elem1->_label, "Value1" );
BOOST_CHECK_EQUAL( elem1->_type, eTypeAscii );
BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked );
BOOST_CHECK_EQUAL( elem1->_status, eStatusUnknown );
elem1->_status = eStatusSkip;

std::shared_ptr< Element > elem2( new Element( elem1->next(), elem1 ) );
Expand Down Expand Up @@ -468,7 +467,7 @@ BOOST_AUTO_TEST_CASE( basic_element_next_repetition_first )
BOOST_CHECK_EQUAL( elem1->_id, "value1" );
BOOST_CHECK_EQUAL( elem1->_label, "Value1" );
BOOST_CHECK_EQUAL( elem1->_type, eTypeAscii );
BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked );
BOOST_CHECK_EQUAL( elem1->_status, eStatusUnknown );
elem1->_status = eStatusValid;

std::shared_ptr< Element > elem2( new Element( elem1->next(), elem1 ) );
Expand Down Expand Up @@ -512,7 +511,7 @@ BOOST_AUTO_TEST_CASE( basic_element_next_repetition_last )
BOOST_CHECK_EQUAL( elem1->_id, "value1" );
BOOST_CHECK_EQUAL( elem1->_label, "Value1" );
BOOST_CHECK_EQUAL( elem1->_type, eTypeAscii );
BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked );
BOOST_CHECK_EQUAL( elem1->_status, eStatusUnknown );
elem1->_status = eStatusValid;

std::shared_ptr< Element > elem2( new Element( elem1->next(), elem1 ) );
Expand Down Expand Up @@ -573,7 +572,7 @@ BOOST_AUTO_TEST_CASE( basic_element_next_repetition_group )
BOOST_CHECK_EQUAL( elem1->_id, "value1" );
BOOST_CHECK_EQUAL( elem1->_label, "Value1" );
BOOST_CHECK_EQUAL( elem1->_type, eTypeAscii );
BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked );
BOOST_CHECK_EQUAL( elem1->_status, eStatusUnknown );
elem1->_status = eStatusValid;

std::shared_ptr< Element > elem2( new Element( elem1->next(), elem1, elem1 ) );
Expand Down Expand Up @@ -650,7 +649,7 @@ BOOST_AUTO_TEST_CASE( basic_element_next_repetition_group )
BOOST_CHECK_EQUAL( elem1->_id, "value1" );
BOOST_CHECK_EQUAL( elem1->_label, "Value1" );
BOOST_CHECK_EQUAL( elem1->_type, eTypeAscii );
BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked );
BOOST_CHECK_EQUAL( elem1->_status, eStatusUnknown );
elem1->_status = eStatusValid;

std::shared_ptr< Element > elem2( new Element( elem1->next(), elem1, elem1 ) );
Expand Down

0 comments on commit 607537c

Please sign in to comment.