Skip to content

Commit

Permalink
addressing multiple windows issues
Browse files Browse the repository at this point in the history
  * #490 - use unique_ptr and roll our own swap
  * #491 - use C++11 random uniform distribution on the range of indices
  • Loading branch information
chambbj committed Sep 25, 2014
1 parent c24dbb2 commit 05ef8a5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/unit/PointBufferTest.cpp
Expand Up @@ -32,6 +32,8 @@
* OF SUCH DAMAGE.
****************************************************************************/

#include <random>

#include <boost/test/unit_test.hpp>
#include <boost/cstdint.hpp>
#include <boost/property_tree/xml_parser.hpp>
Expand Down Expand Up @@ -266,12 +268,19 @@ BOOST_AUTO_TEST_CASE(bigfile)
}

// Test some random access.
PointId ids[NUM_PTS];
std::unique_ptr<PointId[]> ids(new PointId[NUM_PTS]);
for (PointId idx = 0; idx < NUM_PTS; ++idx)
ids[idx] = idx;
// Do a bunch of random swaps.
std::default_random_engine generator;
std::uniform_int_distribution<PointId> distribution(0, NUM_PTS-1);
for (PointId idx = 0; idx < NUM_PTS; ++idx)
std::swap(ids[idx], ids[random() % NUM_PTS]);
{
PointId y = distribution(generator);
PointId temp = std::move(ids[idx]);
ids[idx] = std::move(ids[y]);
ids[y] = std::move(temp);
}

for (PointId idx = 0; idx < NUM_PTS; ++idx)
{
Expand Down

0 comments on commit 05ef8a5

Please sign in to comment.