Refactors test cases to use gtest
authorPeizhao Ou <peizhaoo@uci.edu>
Fri, 9 Feb 2018 08:46:01 +0000 (00:46 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Fri, 9 Feb 2018 08:46:01 +0000 (00:46 -0800)
test/junction_parallel_driver.cpp
test/junction_sequential_driver.cpp

index 4fe6d29ac2c538ab1e5822b3a8e1b345c2d5b48b..b9f5d8f07e82f094b007f3b540ea6508dc128a33 100644 (file)
@@ -6,15 +6,12 @@
 #include <gtest/gtest.h>
 
 #include <algorithm>
-#include <cassert>
-#include <chrono>
-#include <iostream>
 #include <memory>
 #include <random>
 
 namespace junction_test {
 
-class JunctionMapInsDelFindTest : public ::testing::Test {
+class JunctionMapInsDelFindTest_Parallel : public ::testing::Test {
 protected:
   typedef junction::ConcurrentMap_Grampa<size_t, size_t> GrampaMap;
   typedef junction::ConcurrentMap_Linear<size_t, size_t> LinearMap;
@@ -112,8 +109,7 @@ protected:
     return map->get(key) != ((Key)0);
   }
 
-  template <typename Map>
-  void run_test(Map* map, size_t pass_count) {
+  template <typename Map> void run_test(Map* map, size_t pass_count) {
     auto qsbrContext = junction::DefaultQSBR.createContext();
 
     std::random_device rd;
@@ -162,28 +158,28 @@ protected:
   }
 };
 
-const unsigned JunctionMapInsDelFindTest::s_nInsertPercentage;
-const unsigned JunctionMapInsDelFindTest::s_nDeletePercentage;
-const unsigned int JunctionMapInsDelFindTest::kShuffleSize;
-JunctionMapInsDelFindTest::actions JunctionMapInsDelFindTest::s_arrShuffle
-    [JunctionMapInsDelFindTest::kShuffleSize];
+const unsigned JunctionMapInsDelFindTest_Parallel::s_nInsertPercentage;
+const unsigned JunctionMapInsDelFindTest_Parallel::s_nDeletePercentage;
+const unsigned int JunctionMapInsDelFindTest_Parallel::kShuffleSize;
+JunctionMapInsDelFindTest_Parallel::actions JunctionMapInsDelFindTest_Parallel::
+    s_arrShuffle[JunctionMapInsDelFindTest_Parallel::kShuffleSize];
 
-TEST_F(JunctionMapInsDelFindTest, JunctionMapCrude) {
+TEST_F(JunctionMapInsDelFindTest_Parallel, JunctionMapCrude) {
   std::unique_ptr<CrudeMap> map(new CrudeMap(kMapSize * 32));
   run_test(map.get(), kCrudePassCount);
 }
 
-TEST_F(JunctionMapInsDelFindTest, JunctionMapLeapfrog) {
+TEST_F(JunctionMapInsDelFindTest_Parallel, JunctionMapLeapfrog) {
   std::unique_ptr<LeapfrogMap> map(new LeapfrogMap());
   run_test(map.get(), kLeapfrogPassCount);
 }
 
-TEST_F(JunctionMapInsDelFindTest, JunctionMapLinear) {
+TEST_F(JunctionMapInsDelFindTest_Parallel, JunctionMapLinear) {
   std::unique_ptr<LinearMap> map(new LinearMap());
   run_test(map.get(), kLinearPassCount);
 }
 
-TEST_F(JunctionMapInsDelFindTest, JunctionMapGrampa) {
+TEST_F(JunctionMapInsDelFindTest_Parallel, JunctionMapGrampa) {
   std::unique_ptr<GrampaMap> map(new GrampaMap());
   run_test(map.get(), kGrampaPassCount);
 }
@@ -194,5 +190,5 @@ int main(int argc, char** argv) {
   // Init Google test
   ::testing::InitGoogleTest(&argc, argv);
   int result = RUN_ALL_TESTS();
-  return 0;
+  return result;
 }
index d0164387950f63a585733dde3ce66a531ec5ceb6..f7779e4bff4297d31674cd811f081dbbf4df1ec5 100644 (file)
@@ -1,14 +1,12 @@
-#include <cassert>
-#include <chrono>
-#include <iostream>
 #include <junction/ConcurrentMap_Crude.h>
 #include <junction/ConcurrentMap_Grampa.h>
 #include <junction/ConcurrentMap_Leapfrog.h>
 #include <junction/ConcurrentMap_Linear.h>
-#include <memory>
 
 #include <gtest/gtest.h>
 
+#include <memory>
+
 namespace junction_test {
 
 class JunctionMapInsDelFindTest : public ::testing::Test {