Fixed Map_find_string test
authorkhizmax <libcds.dev@gmail.com>
Thu, 10 Dec 2015 19:40:25 +0000 (22:40 +0300)
committerkhizmax <libcds.dev@gmail.com>
Thu, 10 Dec 2015 19:40:25 +0000 (22:40 +0300)
tests/unit/map2/map_find_string.cpp
tests/unit/map2/map_find_string.h

index ec08b9bc92af2b224e662e1f4ce9a5cadca916b8..9ed39bdf404ef951a8096fa7b13cf267bdde4a9a 100644 (file)
@@ -18,13 +18,13 @@ namespace map2 {
         size_t nSize = arrString.size();
         if ( nSize > c_nMapSize )
             nSize = c_nMapSize;
-        m_Arr.resize( nSize );
+        m_Arr.reserve( nSize );
 
         nSize = 0;
-        for ( size_t i = 0; i < nSize; ++i ) {
-            m_Arr[i].pKey = &( arrString[i] );
-            m_Arr[i].bExists = CppUnitMini::Rand( 100 ) <= nPercent;
-            if ( m_Arr[i].bExists )
+        for ( size_t i = 0; i < nSize && i < arrString.size(); ++i ) {
+        bool bExists = CppUnitMini::Rand( 100 ) <= nPercent;
+            m_Arr.push_back( { &arrString.at(i), bExists } );
+            if ( bExists )
                 ++nSize;
         }
         c_nMapSize = nSize;
@@ -49,12 +49,10 @@ namespace map2 {
         if ( c_nThreadCount == 0 )
             c_nThreadCount = std::thread::hardware_concurrency();
 
-        CPPUNIT_MSG( "Generating test data...");
+        CPPUNIT_MSG( "Generating test data...\n");
         cds::OS::Timer    timer;
         generateSequence();
-        CPPUNIT_MSG( "   Duration=" << timer.duration() );
-        CPPUNIT_MSG( "Map size=" << c_nMapSize << " find key loop=" << m_Arr.size() << " (" << c_nPercentExists << "% success)" );
-        CPPUNIT_MSG( "Thread count=" << c_nThreadCount << " Pass count=" << c_nPassCount );
+        CPPUNIT_MSG( "   Duration=" << timer.duration() << "\n" );
 
     }
 } // namespace map2
index 0edfdb06cfebeda30e8acb6aa635df514dd09ceb..0577df7d9f10204193e1fb7b2d74275a5b74f19f 100644 (file)
@@ -152,6 +152,9 @@ namespace map2 {
             typedef TestThread<Map>     Thread;
             cds::OS::Timer    timer;
 
+            CPPUNIT_MSG( "Map size=" << c_nMapSize << " find key loop=" << m_Arr.size() << " (" << c_nPercentExists << "% success)" );
+            CPPUNIT_MSG( "Thread count=" << c_nThreadCount << " Pass count=" << c_nPassCount );
+
             // Fill the map
             CPPUNIT_MSG( "  Fill map...");
             timer.reset();