diff --git a/libraries/ElementChecker/src/ElementChecker/Checker/Checker.cpp b/libraries/ElementChecker/src/ElementChecker/Checker/Checker.cpp index 50f1671..77e2162 100644 --- a/libraries/ElementChecker/src/ElementChecker/Checker/Checker.cpp +++ b/libraries/ElementChecker/src/ElementChecker/Checker/Checker.cpp @@ -116,7 +116,7 @@ void Checker::check( const std::shared_ptr< basic_element::Element > element ) status = eStatusValid; if( status == eStatusInvalid ) - element->_error += "Invalid value "; + element->_error += "Invalid value - "; break; } @@ -145,6 +145,7 @@ void Checker::check( const std::shared_ptr< basic_element::Element > element ) std::string errorMessage; if( ! isIterationValid( element->getPrevious(), errorMessage ) ) { + LOG_ERROR( element->_id << ": " << errorMessage ); element->_error += errorMessage; _elementList.push_back( element ); } @@ -154,19 +155,22 @@ void Checker::check( const std::shared_ptr< basic_element::Element > element ) _elementList.push_back( element ); } -bool Checker::isIterationValid( const std::shared_ptr< basic_element::Element > element, const std::string& errorMessage ) +bool Checker::isIterationValid( const std::shared_ptr< basic_element::Element > element, std::string& errorMessage ) { if( element->_repetExpr.empty() ) return true; + std::stringstream error; for( std::pair< std::string, std::string > repetPair : element->_repetExpr ) { - LOG_ERROR( "Checker: repetitions: " << repetPair.first << " # " << repetPair.second ); if( repetPair.first == repetPair.second ) { ExpressionParser repetParser( _elementList ); size_t repetNumber = repetParser.getExpressionResult< size_t >( repetPair.first ); - LOG_FATAL( "////// REPETITION : " << repetNumber ); + // LOG_FATAL( "////// REPETITION : " << element->_iteration << " / " << repetNumber ); + if( element->_iteration == repetNumber ) + return true; + error << element->_iteration << " / " << repetNumber; } else { @@ -179,13 +183,14 @@ bool Checker::isIterationValid( const std::shared_ptr< basic_element::Element > if( ! repetPair.second.empty() ) repetMax = repetParser.getExpressionResult< size_t >( repetPair.second ); - // if( repetMax != 0 && repetMin > repetMax ) - // repetRange.push_back( std::make_pair( repetMax, repetMin ) ); - // else - // repetRange.push_back( std::make_pair( repetMin, repetMax ) ); - LOG_FATAL( "////// REPETITIONS : " << repetMin << " / " << repetMax ); + // LOG_FATAL( "////// REPETITIONS : " << element->_iteration << " / [" << repetMin << ", " << repetMax << "]" ); + if( repetMin <= element->_iteration ) + if( repetMax == 0 || repetMax >= element->_iteration ) + return true; + error << element->_iteration << " / [" << repetMin << ", " << repetMax << "]"; } } + errorMessage = "Out of repetition range (" + error.str() + ") - "; return false; } diff --git a/libraries/ElementChecker/src/ElementChecker/Checker/Checker.hpp b/libraries/ElementChecker/src/ElementChecker/Checker/Checker.hpp index 2f0f95c..ead1c8f 100644 --- a/libraries/ElementChecker/src/ElementChecker/Checker/Checker.hpp +++ b/libraries/ElementChecker/src/ElementChecker/Checker/Checker.hpp @@ -19,7 +19,7 @@ class Checker void check( const std::shared_ptr< basic_element::Element > element ); std::vector< std::shared_ptr< basic_element::Element > > getElementList() { return _elementList; } private: - bool isIterationValid( const std::shared_ptr< basic_element::Element > element, const std::string& errorMessage ); + bool isIterationValid( const std::shared_ptr< basic_element::Element > element, std::string& errorMessage ); private: std::vector< std::shared_ptr< basic_element::Element > > _elementList; diff --git a/libraries/ElementChecker/test/checkerTest.hpp b/libraries/ElementChecker/test/checkerTest.hpp index 65f4652..588ee54 100644 --- a/libraries/ElementChecker/test/checkerTest.hpp +++ b/libraries/ElementChecker/test/checkerTest.hpp @@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE( element_checker_checker_data ) checker.check( elem ); BOOST_CHECK_EQUAL( elem->_status, eStatusInvalid ); - BOOST_CHECK_EQUAL( elem->_error, "Invalid value " ); + BOOST_CHECK( elem->_error.find( "Invalid value" ) != std::string::npos ); BOOST_CHECK_EQUAL( checker.getElementList().size(), 4 ); } } @@ -167,9 +167,7 @@ BOOST_AUTO_TEST_CASE( element_checker_checker_number ) BOOST_AUTO_TEST_CASE( element_checker_checker_repetition ) { - LOG_INFO( "\n>>> element_checker_checker_repetition <<<" ); - { - std::string jsonString = R"*( + std::string jsonStringBegin = R"*( { "header": [ { @@ -183,7 +181,10 @@ BOOST_AUTO_TEST_CASE( element_checker_checker_repetition ) "label": "Value2", "type": "ascii", "values": "WAVE2", - "repeated": "3" + "repeated": )*"; + + + std::string jsonStringEnd = R"*( }, { "id": "value3", @@ -195,8 +196,118 @@ BOOST_AUTO_TEST_CASE( element_checker_checker_repetition ) } )*"; + LOG_INFO( "\n>>> element_checker_checker_repetition <<<" ); + { + std::string jsonStringRepetition = R"*("3")*"; + + spec_reader::Specification spec; + spec.setFromString( jsonStringBegin + jsonStringRepetition + jsonStringEnd ); + std::shared_ptr< spec_reader::SpecNode > node = spec.getFirstNode(); + BOOST_CHECK_EQUAL( node->getId(), "value1" ); + BOOST_CHECK_EQUAL( node->next()->getId(), "value2" ); + BOOST_CHECK_EQUAL( node->next()->next()->getId(), "value3" ); + BOOST_CHECK( node->next()->next()->next() == nullptr ); + + Checker checker; + const char buff1[5] { 'W', 'A', 'V', 'E', '1' }; + const char buff2[5] { 'W', 'A', 'V', 'E', '2' }; + const char buff3[5] { 'W', 'A', 'V', 'E', '3' }; + + std::shared_ptr< basic_element::Element > elem1( new basic_element::Element( node ) ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked ); + elem1->set( (const char*)&buff1, 5 ); + checker.check( elem1 ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem2( new basic_element::Element( elem1->next(), elem1 ) ); + elem2->set( (const char*)&buff2, 5 ); + checker.check( elem2 ); + BOOST_CHECK_EQUAL( elem2->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem3( new basic_element::Element( elem2->next(), elem2 ) ); + elem3->set( (const char*)&buff2, 5 ); + checker.check( elem3 ); + BOOST_CHECK_EQUAL( elem3->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem4( new basic_element::Element( elem3->next(), elem3 ) ); + elem4->set( (const char*)&buff2, 5 ); + checker.check( elem4 ); + BOOST_CHECK_EQUAL( elem4->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem5( new basic_element::Element( elem4->next(), elem4 ) ); + elem5->set( (const char*)&buff3, 5 ); + checker.check( elem5 ); + BOOST_CHECK_EQUAL( elem5->_status, eStatusInvalid ); + BOOST_CHECK( elem5->_error.find( "repetition" ) == std::string::npos ); + + std::shared_ptr< basic_element::Element > elem6( new basic_element::Element( elem5->next(), elem5 ) ); + elem6->set( (const char*)&buff3, 5 ); + checker.check( elem6 ); + BOOST_CHECK_EQUAL( elem6->_status, eStatusValid ); + + BOOST_CHECK( elem6->next() == nullptr ); + } + LOG_INFO( "\n>>> element_checker_checker_repetition suite <<<" ); + { + std::string jsonStringRepetition = R"*( [ + { "min": "2" } + ] )*"; + + spec_reader::Specification spec; + spec.setFromString( jsonStringBegin + jsonStringRepetition + jsonStringEnd ); + std::shared_ptr< spec_reader::SpecNode > node = spec.getFirstNode(); + BOOST_CHECK_EQUAL( node->getId(), "value1" ); + BOOST_CHECK_EQUAL( node->next()->getId(), "value2" ); + BOOST_CHECK_EQUAL( node->next()->next()->getId(), "value3" ); + BOOST_CHECK( node->next()->next()->next() == nullptr ); + + Checker checker; + const char buff1[5] { 'W', 'A', 'V', 'E', '1' }; + const char buff2[5] { 'W', 'A', 'V', 'E', '2' }; + const char buff3[5] { 'W', 'A', 'V', 'E', '3' }; + + std::shared_ptr< basic_element::Element > elem1( new basic_element::Element( node ) ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked ); + elem1->set( (const char*)&buff1, 5 ); + checker.check( elem1 ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem2( new basic_element::Element( elem1->next(), elem1 ) ); + elem2->set( (const char*)&buff2, 5 ); + checker.check( elem2 ); + BOOST_CHECK_EQUAL( elem2->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem3( new basic_element::Element( elem2->next(), elem2 ) ); + elem3->set( (const char*)&buff2, 5 ); + checker.check( elem3 ); + BOOST_CHECK_EQUAL( elem3->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem4( new basic_element::Element( elem3->next(), elem3 ) ); + elem4->set( (const char*)&buff2, 5 ); + checker.check( elem4 ); + BOOST_CHECK_EQUAL( elem4->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem5( new basic_element::Element( elem4->next(), elem4 ) ); + elem5->set( (const char*)&buff3, 5 ); + checker.check( elem5 ); + BOOST_CHECK_EQUAL( elem5->_status, eStatusInvalid ); + BOOST_CHECK( elem5->_error.find( "repetition" ) == std::string::npos ); + + std::shared_ptr< basic_element::Element > elem6( new basic_element::Element( elem5->next(), elem5 ) ); + elem6->set( (const char*)&buff3, 5 ); + checker.check( elem6 ); + BOOST_CHECK_EQUAL( elem6->_status, eStatusValid ); + + BOOST_CHECK( elem6->next() == nullptr ); + } + LOG_INFO( "\n>>> element_checker_checker_repetition suite 2 <<<" ); + { + std::string jsonStringRepetition = R"*( [ + { "min": "2", "max": "4" } + ] )*"; + spec_reader::Specification spec; - spec.setFromString( jsonString ); + spec.setFromString( jsonStringBegin + jsonStringRepetition + jsonStringEnd ); std::shared_ptr< spec_reader::SpecNode > node = spec.getFirstNode(); BOOST_CHECK_EQUAL( node->getId(), "value1" ); BOOST_CHECK_EQUAL( node->next()->getId(), "value2" ); @@ -233,6 +344,7 @@ BOOST_AUTO_TEST_CASE( element_checker_checker_repetition ) elem5->set( (const char*)&buff3, 5 ); checker.check( elem5 ); BOOST_CHECK_EQUAL( elem5->_status, eStatusInvalid ); + BOOST_CHECK( elem5->_error.find( "repetition" ) == std::string::npos ); std::shared_ptr< basic_element::Element > elem6( new basic_element::Element( elem5->next(), elem5 ) ); elem6->set( (const char*)&buff3, 5 ); @@ -241,6 +353,307 @@ BOOST_AUTO_TEST_CASE( element_checker_checker_repetition ) BOOST_CHECK( elem6->next() == nullptr ); } + LOG_INFO( "\n>>> element_checker_checker_repetition suite 3 <<<" ); + { + std::string jsonStringRepetition = R"*( [ + { "max": "4" } + ] )*"; + + spec_reader::Specification spec; + spec.setFromString( jsonStringBegin + jsonStringRepetition + jsonStringEnd ); + std::shared_ptr< spec_reader::SpecNode > node = spec.getFirstNode(); + BOOST_CHECK_EQUAL( node->getId(), "value1" ); + BOOST_CHECK_EQUAL( node->next()->getId(), "value2" ); + BOOST_CHECK_EQUAL( node->next()->next()->getId(), "value3" ); + BOOST_CHECK( node->next()->next()->next() == nullptr ); + + Checker checker; + const char buff1[5] { 'W', 'A', 'V', 'E', '1' }; + const char buff2[5] { 'W', 'A', 'V', 'E', '2' }; + const char buff3[5] { 'W', 'A', 'V', 'E', '3' }; + + std::shared_ptr< basic_element::Element > elem1( new basic_element::Element( node ) ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked ); + elem1->set( (const char*)&buff1, 5 ); + checker.check( elem1 ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem2( new basic_element::Element( elem1->next(), elem1 ) ); + elem2->set( (const char*)&buff2, 5 ); + checker.check( elem2 ); + BOOST_CHECK_EQUAL( elem2->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem3( new basic_element::Element( elem2->next(), elem2 ) ); + elem3->set( (const char*)&buff2, 5 ); + checker.check( elem3 ); + BOOST_CHECK_EQUAL( elem3->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem4( new basic_element::Element( elem3->next(), elem3 ) ); + elem4->set( (const char*)&buff2, 5 ); + checker.check( elem4 ); + BOOST_CHECK_EQUAL( elem4->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem5( new basic_element::Element( elem4->next(), elem4 ) ); + elem5->set( (const char*)&buff3, 5 ); + checker.check( elem5 ); + BOOST_CHECK_EQUAL( elem5->_status, eStatusInvalid ); + BOOST_CHECK( elem5->_error.find( "repetition" ) == std::string::npos ); + + std::shared_ptr< basic_element::Element > elem6( new basic_element::Element( elem5->next(), elem5 ) ); + elem6->set( (const char*)&buff3, 5 ); + checker.check( elem6 ); + BOOST_CHECK_EQUAL( elem6->_status, eStatusValid ); + + BOOST_CHECK( elem6->next() == nullptr ); + } +} + +BOOST_AUTO_TEST_CASE( element_checker_checker_repetition_invalid ) +{ + std::string jsonStringBegin = R"*( + { + "header": [ + { + "id": "value1", + "label": "Value1", + "type": "ascii", + "values": "WAVE1" + }, + { + "id": "value2", + "label": "Value2", + "type": "ascii", + "values": "WAVE2", + "repeated": )*"; + + + std::string jsonStringEnd = R"*( + }, + { + "id": "value3", + "label": "Value3", + "type": "ascii", + "values": "WAVE3" + } + ] + } + )*"; + + LOG_INFO( "\n>>> element_checker_checker_repetition_invalid <<<" ); + { + std::string jsonStringRepetition = R"*("3")*"; + + spec_reader::Specification spec; + spec.setFromString( jsonStringBegin + jsonStringRepetition + jsonStringEnd ); + std::shared_ptr< spec_reader::SpecNode > node = spec.getFirstNode(); + BOOST_CHECK_EQUAL( node->getId(), "value1" ); + BOOST_CHECK_EQUAL( node->next()->getId(), "value2" ); + BOOST_CHECK_EQUAL( node->next()->next()->getId(), "value3" ); + BOOST_CHECK( node->next()->next()->next() == nullptr ); + + Checker checker; + const char buff1[5] { 'W', 'A', 'V', 'E', '1' }; + const char buff2[5] { 'W', 'A', 'V', 'E', '2' }; + const char buff3[5] { 'W', 'A', 'V', 'E', '3' }; + + std::shared_ptr< basic_element::Element > elem1( new basic_element::Element( node ) ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked ); + elem1->set( (const char*)&buff1, 5 ); + checker.check( elem1 ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem2( new basic_element::Element( elem1->next(), elem1 ) ); + elem2->set( (const char*)&buff2, 5 ); + checker.check( elem2 ); + BOOST_CHECK_EQUAL( elem2->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem3( new basic_element::Element( elem2->next(), elem2 ) ); + elem3->set( (const char*)&buff2, 5 ); + checker.check( elem3 ); + BOOST_CHECK_EQUAL( elem3->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem4( new basic_element::Element( elem3->next(), elem3 ) ); + elem4->set( (const char*)&buff3, 5 ); + checker.check( elem4 ); + BOOST_CHECK_EQUAL( elem4->_status, eStatusInvalid ); + BOOST_CHECK( elem4->_error.find( "repetition" ) != std::string::npos ); + + std::shared_ptr< basic_element::Element > elem5( new basic_element::Element( elem4->next(), elem4 ) ); + elem5->set( (const char*)&buff3, 5 ); + checker.check( elem5 ); + BOOST_CHECK_EQUAL( elem5->_status, eStatusValid ); + + BOOST_CHECK( elem5->next() == nullptr ); + } + LOG_INFO( "\n>>> element_checker_checker_repetition_invalid suite <<<" ); + { + std::string jsonStringRepetition = R"*( [ + { "min": "2" } + ] )*"; + + spec_reader::Specification spec; + spec.setFromString( jsonStringBegin + jsonStringRepetition + jsonStringEnd ); + std::shared_ptr< spec_reader::SpecNode > node = spec.getFirstNode(); + BOOST_CHECK_EQUAL( node->getId(), "value1" ); + BOOST_CHECK_EQUAL( node->next()->getId(), "value2" ); + BOOST_CHECK_EQUAL( node->next()->next()->getId(), "value3" ); + BOOST_CHECK( node->next()->next()->next() == nullptr ); + + Checker checker; + const char buff1[5] { 'W', 'A', 'V', 'E', '1' }; + const char buff2[5] { 'W', 'A', 'V', 'E', '2' }; + const char buff3[5] { 'W', 'A', 'V', 'E', '3' }; + + std::shared_ptr< basic_element::Element > elem1( new basic_element::Element( node ) ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked ); + elem1->set( (const char*)&buff1, 5 ); + checker.check( elem1 ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem2( new basic_element::Element( elem1->next(), elem1 ) ); + elem2->set( (const char*)&buff2, 5 ); + checker.check( elem2 ); + BOOST_CHECK_EQUAL( elem2->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem3( new basic_element::Element( elem2->next(), elem2 ) ); + elem3->set( (const char*)&buff3, 5 ); + checker.check( elem3 ); + BOOST_CHECK_EQUAL( elem3->_status, eStatusInvalid ); + BOOST_CHECK( elem3->_error.find( "repetition" ) != std::string::npos ); + + std::shared_ptr< basic_element::Element > elem4( new basic_element::Element( elem3->next(), elem3 ) ); + elem4->set( (const char*)&buff3, 5 ); + checker.check( elem4 ); + BOOST_CHECK_EQUAL( elem4->_status, eStatusValid ); + + BOOST_CHECK( elem4->next() == nullptr ); + } + LOG_INFO( "\n>>> element_checker_checker_repetition_invalid suite 2 <<<" ); + { + std::string jsonStringRepetition = R"*( [ + { "min": "2", "max": "4" } + ] )*"; + + spec_reader::Specification spec; + spec.setFromString( jsonStringBegin + jsonStringRepetition + jsonStringEnd ); + std::shared_ptr< spec_reader::SpecNode > node = spec.getFirstNode(); + BOOST_CHECK_EQUAL( node->getId(), "value1" ); + BOOST_CHECK_EQUAL( node->next()->getId(), "value2" ); + BOOST_CHECK_EQUAL( node->next()->next()->getId(), "value3" ); + BOOST_CHECK( node->next()->next()->next() == nullptr ); + + Checker checker; + const char buff1[5] { 'W', 'A', 'V', 'E', '1' }; + const char buff2[5] { 'W', 'A', 'V', 'E', '2' }; + const char buff3[5] { 'W', 'A', 'V', 'E', '3' }; + + std::shared_ptr< basic_element::Element > elem1( new basic_element::Element( node ) ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked ); + elem1->set( (const char*)&buff1, 5 ); + checker.check( elem1 ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem2( new basic_element::Element( elem1->next(), elem1 ) ); + elem2->set( (const char*)&buff2, 5 ); + checker.check( elem2 ); + BOOST_CHECK_EQUAL( elem2->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem3( new basic_element::Element( elem2->next(), elem2 ) ); + elem3->set( (const char*)&buff2, 5 ); + checker.check( elem3 ); + BOOST_CHECK_EQUAL( elem3->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem4( new basic_element::Element( elem3->next(), elem3 ) ); + elem4->set( (const char*)&buff2, 5 ); + checker.check( elem4 ); + BOOST_CHECK_EQUAL( elem4->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem5( new basic_element::Element( elem4->next(), elem4 ) ); + elem5->set( (const char*)&buff2, 5 ); + checker.check( elem5 ); + BOOST_CHECK_EQUAL( elem5->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem6( new basic_element::Element( elem5->next(), elem5 ) ); + elem6->set( (const char*)&buff2, 5 ); + checker.check( elem6 ); + BOOST_CHECK_EQUAL( elem6->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem7( new basic_element::Element( elem6->next(), elem6 ) ); + elem7->set( (const char*)&buff3, 5 ); + checker.check( elem7 ); + BOOST_CHECK_EQUAL( elem7->_status, eStatusInvalid ); + BOOST_CHECK( elem7->_error.find( "repetition" ) != std::string::npos ); + + std::shared_ptr< basic_element::Element > elem8( new basic_element::Element( elem7->next(), elem7 ) ); + elem8->set( (const char*)&buff3, 5 ); + checker.check( elem8 ); + BOOST_CHECK_EQUAL( elem8->_status, eStatusValid ); + + BOOST_CHECK( elem8->next() == nullptr ); + } + LOG_INFO( "\n>>> element_checker_checker_repetition_invalid suite 3 <<<" ); + { + std::string jsonStringRepetition = R"*( [ + { "max": "4" } + ] )*"; + + spec_reader::Specification spec; + spec.setFromString( jsonStringBegin + jsonStringRepetition + jsonStringEnd ); + std::shared_ptr< spec_reader::SpecNode > node = spec.getFirstNode(); + BOOST_CHECK_EQUAL( node->getId(), "value1" ); + BOOST_CHECK_EQUAL( node->next()->getId(), "value2" ); + BOOST_CHECK_EQUAL( node->next()->next()->getId(), "value3" ); + BOOST_CHECK( node->next()->next()->next() == nullptr ); + + Checker checker; + const char buff1[5] { 'W', 'A', 'V', 'E', '1' }; + const char buff2[5] { 'W', 'A', 'V', 'E', '2' }; + const char buff3[5] { 'W', 'A', 'V', 'E', '3' }; + + std::shared_ptr< basic_element::Element > elem1( new basic_element::Element( node ) ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusNotChecked ); + elem1->set( (const char*)&buff1, 5 ); + checker.check( elem1 ); + BOOST_CHECK_EQUAL( elem1->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem2( new basic_element::Element( elem1->next(), elem1 ) ); + elem2->set( (const char*)&buff2, 5 ); + checker.check( elem2 ); + BOOST_CHECK_EQUAL( elem2->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem3( new basic_element::Element( elem2->next(), elem2 ) ); + elem3->set( (const char*)&buff2, 5 ); + checker.check( elem3 ); + BOOST_CHECK_EQUAL( elem3->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem4( new basic_element::Element( elem3->next(), elem3 ) ); + elem4->set( (const char*)&buff2, 5 ); + checker.check( elem4 ); + BOOST_CHECK_EQUAL( elem4->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem5( new basic_element::Element( elem4->next(), elem4 ) ); + elem5->set( (const char*)&buff2, 5 ); + checker.check( elem5 ); + BOOST_CHECK_EQUAL( elem5->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem6( new basic_element::Element( elem5->next(), elem5 ) ); + elem6->set( (const char*)&buff2, 5 ); + checker.check( elem6 ); + BOOST_CHECK_EQUAL( elem6->_status, eStatusValid ); + + std::shared_ptr< basic_element::Element > elem7( new basic_element::Element( elem6->next(), elem6 ) ); + elem7->set( (const char*)&buff3, 5 ); + checker.check( elem7 ); + BOOST_CHECK_EQUAL( elem7->_status, eStatusInvalid ); + BOOST_CHECK( elem7->_error.find( "repetition" ) != std::string::npos ); + + std::shared_ptr< basic_element::Element > elem8( new basic_element::Element( elem7->next(), elem7 ) ); + elem8->set( (const char*)&buff3, 5 ); + checker.check( elem8 ); + BOOST_CHECK_EQUAL( elem8->_status, eStatusValid ); + + BOOST_CHECK( elem8->next() == nullptr ); + } } BOOST_AUTO_TEST_SUITE_END()