Changeset 2936


Ignore:
Timestamp:
Jan 1, 2013, 7:58:24 AM (9 years ago)
Author:
Peter
Message:

avoid repeating code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.10-stable/test/rng-mt.cc

    r2935 r2936  
    104104
    105105
     106std::vector<int> rnd_vec(void)
     107{
     108  std::vector<int> x(10);
     109  Visitor visitor1(x);
     110  boost::thread_group threads;
     111  threads.create_thread(visitor1);
     112  threads.join_all();
     113  return x;
     114}
     115
     116
    106117void test2(test::Suite& suite)
    107118{
     
    109120  // test that we get same number with same seed
    110121  RNG::instance()->seed(0);
    111   std::vector<int> x(10);
    112   Visitor visitor1(x);
    113   boost::thread_group threads;
    114   threads.create_thread(visitor1);
    115   threads.join_all();
    116   // copy result from visitor1 to variable y
    117   std::vector<int> y(x);
     122  std::vector<int> y = rnd_vec();
    118123  suite.out() << "y: ";
    119124  std::copy(y.begin(), y.end(), std::ostream_iterator<int>(suite.out(), " "));
     
    121126
    122127  RNG::instance()->seed(0);
    123   boost::thread_group threads2;
    124   threads2.create_thread(visitor1);
    125   threads2.join_all();
     128  std::vector<int> x = rnd_vec();
    126129  suite.out() << "x: ";
    127130  std::copy(x.begin(), x.end(), std::ostream_iterator<int>(suite.out(), " "));
     
    150153  suite.out() << std::endl;
    151154
    152   std::vector<int> y(x);
    153   Visitor visitor1(y);
    154   boost::thread_group threads;
    155   threads.create_thread(visitor1);
    156   threads.join_all();
    157 
     155  std::vector<int> y = rnd_vec();
    158156  suite.out() << "y: ";
    159157  std::copy(y.begin(), y.end(), std::ostream_iterator<int>(suite.out(), " "));
Note: See TracChangeset for help on using the changeset viewer.