From: khizmax Date: Thu, 10 Dec 2015 19:40:25 +0000 (+0300) Subject: Fixed Map_find_string test X-Git-Tag: v2.1.0~36 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=18cbeeacc1a02e748b86a0ca624e6099714add96;p=libcds.git Fixed Map_find_string test --- diff --git a/tests/unit/map2/map_find_string.cpp b/tests/unit/map2/map_find_string.cpp index ec08b9bc..9ed39bdf 100644 --- a/tests/unit/map2/map_find_string.cpp +++ b/tests/unit/map2/map_find_string.cpp @@ -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 diff --git a/tests/unit/map2/map_find_string.h b/tests/unit/map2/map_find_string.h index 0edfdb06..0577df7d 100644 --- a/tests/unit/map2/map_find_string.h +++ b/tests/unit/map2/map_find_string.h @@ -152,6 +152,9 @@ namespace map2 { typedef TestThread 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();