Refactors sequential misc test cases
[libcds.git] / test / stress / sequential / sequential-misc / seqlock_driver.cpp
index 21313b3..3a7d865 100644 (file)
@@ -20,7 +20,6 @@ static size_t s_nSeqLockPassCount = 2000000;
 class SeqLockTest : public cds_test::stress_fixture {
 protected:
   static size_t sum;
-  static SeqLock *seqlock;
 
   static void SetUpTestCase() {
     cds_test::config const &cfg = get_config("SequentialMisc");
@@ -28,7 +27,7 @@ protected:
     GetConfig(SeqLockPassCount);
   }
 
-  static void ReaderWriterThread(int write_percentage) {
+  static void ReaderWriterThread(SeqLock *seqlock, int write_percentage) {
     for (size_t i = 0; i < s_nSeqLockPassCount; i++) {
       if (rand(100) < write_percentage) {
         sum += seqlock->read();
@@ -40,12 +39,11 @@ protected:
 };
 
 size_t SeqLockTest::sum;
-SeqLock *SeqLockTest::seqlock;
 
 TEST_F(SeqLockTest, SeqLock) {
-  seqlock = new SeqLock();
+  std::unique_ptr<SeqLock> seqlock(new SeqLock());
   for (int write_percentage = 5; write_percentage < 50; write_percentage += 5) {
-    ReaderWriterThread(write_percentage);
+    ReaderWriterThread(seqlock.get(), write_percentage);
   }
 }