Asserting for the hosts items quantity match
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Thu, 29 Sep 2011 04:06:11 +0000 (01:06 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Thu, 29 Sep 2011 04:06:11 +0000 (01:06 -0300)
src/config/option/hostpingintervaloption.cpp
src/config/option/hostpingprotocoloption.cpp
src/config/option/hostportoption.cpp

index 5d7ef3d..a5bf64e 100644 (file)
@@ -62,28 +62,30 @@ bool HostPingIntervalOption::parse(
 )
 {
     size_t hosts_interval_count = 0;
+    size_t hosts_count = 0;
     bool parsed_success = false;
 
     // [host] interval
     if ( vm.count( get_command_string() ) > 0 )
     {
         HostList hosts_list = configuration->get_hosts();
-        HostList::iterator hosts_it = hosts_list.begin();
+        HostList::iterator hosts_list_iterator = hosts_list.begin();
 
         vector<int> hosts_intervals = vm[ get_command_string() ].as< vector<int> >();
         BOOST_FOREACH( int host_interval_in_sec, hosts_intervals )
         {
             BOOST_ASSERT( 0 < host_interval_in_sec );
 
-            HostItem host_item = *hosts_it;
+            HostItem host_item = *hosts_list_iterator;
             host_item->set_interval_in_sec( host_interval_in_sec );
-            ++hosts_it;
+            ++hosts_list_iterator;
 
             GlobalLogger.info() << get_command_string() << "="
                     << host_interval_in_sec << endl;
         }
 
         hosts_interval_count = hosts_intervals.size();
+        hosts_count = hosts_list.size();
         parsed_success = true;
     }
 
@@ -93,7 +95,7 @@ bool HostPingIntervalOption::parse(
     // TODO BOOST_ASSERT( hosts_names_count >= static_cast<size_t>( host_down_limit ) );
 //    BOOST_ASSERT( hosts_names_count == host_port_count );
 //    BOOST_ASSERT( hosts_names_count == host_ping_protocol_count );
-//    BOOST_ASSERT( hosts_names_count == hosts_interval_count );
+    BOOST_ASSERT( hosts_count == hosts_interval_count );
 
     return parsed_success;
 }
index d725feb..8b6af41 100644 (file)
@@ -62,29 +62,31 @@ bool HostPingProtocolOption::parse(
 )
 {
     size_t host_ping_protocol_count = 0;
+    size_t hosts_count = 0;
     bool parsed_success = false;
 
     // [host] ping-protocol
     if ( vm.count( get_command_string() ) > 0 )
     {
         HostList hosts_list = configuration->get_hosts();
-        HostList::iterator hosts_it = hosts_list.begin();
+        HostList::iterator hosts_list_iterator = hosts_list.begin();
 
         vector<string> hosts_protocols = vm[ get_command_string() ].as< vector<string> >();
         BOOST_FOREACH( string protocol_string, hosts_protocols )
         {
             BOOST_ASSERT( !protocol_string.empty() );
 
-            HostItem host_item = *hosts_it;
+            HostItem host_item = *hosts_list_iterator;
             PingProtocol host_protocol = get_ping_protocol_from_string( protocol_string );
             host_item->set_ping_protocol( host_protocol );
-            ++hosts_it;
+            ++hosts_list_iterator;
 
             GlobalLogger.info() << get_command_string() << "="
                     << protocol_string << endl;
         }
 
         host_ping_protocol_count = hosts_protocols.size();
+        hosts_count = hosts_list.size();
         parsed_success = true;
     }
 
@@ -93,7 +95,7 @@ bool HostPingProtocolOption::parse(
     // TODO receive the host_down_limit by parameter, use a std::map to find this configuration inside the Options container
     // TODO BOOST_ASSERT( hosts_names_count >= static_cast<size_t>( host_down_limit ) );
 //    BOOST_ASSERT( hosts_names_count == host_port_count );
-//    BOOST_ASSERT( hosts_names_count == host_ping_protocol_count );
+    BOOST_ASSERT( hosts_count == host_ping_protocol_count );
 //    BOOST_ASSERT( hosts_names_count == hosts_interval_count );
 
     return parsed_success;
index 349b4d4..2fec26a 100644 (file)
@@ -63,27 +63,29 @@ bool HostPortOption::parse(
 )
 {
     size_t host_port_count = 0;
+    size_t hosts_count = 0;
     bool parsed_success = false;
 
     // [host] port
     if ( vm.count( get_command_string() ) > 0 )
     {
         HostList hosts_list = configuration->get_hosts();
-        HostList::iterator hosts_it = hosts_list.begin();
+        HostList::iterator hosts_list_iterator = hosts_list.begin();
 
         vector<int> hosts_ports = vm[ get_command_string() ].as< vector<int> >();
         BOOST_FOREACH( int host_port, hosts_ports )
         {
             BOOST_ASSERT( ( 0 <= host_port ) && ( host_port <= numeric_limits<uint16_t>::max() ) );
 
-            HostItem host_item = *hosts_it;
+            HostItem host_item = *hosts_list_iterator;
             host_item->set_port( static_cast<uint16_t>(host_port) );
-            ++hosts_it;
+            ++hosts_list_iterator;
 
             GlobalLogger.info() <<  get_command_string() << "=" << host_port << endl;
         }
 
         host_port_count = hosts_ports.size();
+        hosts_count = hosts_list.size();
         parsed_success = true;
     }
 
@@ -91,7 +93,7 @@ bool HostPortOption::parse(
 
     // TODO receive the host_down_limit by parameter, use a std::map to find this configuration inside the Options container
     // TODO BOOST_ASSERT( hosts_names_count >= static_cast<size_t>( host_down_limit ) );
-//    BOOST_ASSERT( hosts_names_count == host_port_count );
+    BOOST_ASSERT( hosts_count == host_port_count );
 //    BOOST_ASSERT( hosts_names_count == host_ping_protocol_count );
 //    BOOST_ASSERT( hosts_names_count == hosts_interval_count );