mnemonic-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject incubator-mnemonic git commit: MNEMONIC-149: Verify the consistency and correctness of sorting results
Date Sat, 05 Nov 2016 19:41:38 GMT
Repository: incubator-mnemonic
Updated Branches:
  refs/heads/master 1af3dc1a9 -> 69f4b0689


MNEMONIC-149: Verify the consistency and correctness of sorting results


Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/69f4b068
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/69f4b068
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/69f4b068

Branch: refs/heads/master
Commit: 69f4b06895fcc63215528756c6c0dd091d1ec577
Parents: 1af3dc1
Author: Wang, Gang(Gary) <gang1.wang@intel.com>
Authored: Sat Nov 5 12:09:59 2016 -0700
Committer: Wang, Gang(Gary) <gang1.wang@intel.com>
Committed: Sat Nov 5 12:34:22 2016 -0700

----------------------------------------------------------------------
 .../DurableSinglyLinkedListNGSortTest.java      | 48 +++++++++++++++-----
 1 file changed, 36 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/69f4b068/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
index 72a92e4..1c939d3 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
@@ -104,12 +104,13 @@ public class DurableSinglyLinkedListNGSortTest {
 
     Person<Long> eval;
     DurableSinglyLinkedList<Person<Long>> iternv = firstnv;
-    System.out.printf(" -- Stage 1 Generated---\n");
+    System.out.printf(" --- Stage 1 Generated---\n");
+    long agesum1 = 0L;
     while (null != iternv) {
       eval = iternv.getItem();
-      if (null != eval) {
-        eval.testOutputAge();
-      }
+      Assert.assertNotNull(eval);
+      eval.testOutputAge();
+      agesum1 += eval.getAge();
       iternv = iternv.getNext();
     }
     System.out.printf("\n");
@@ -120,12 +121,14 @@ public class DurableSinglyLinkedListNGSortTest {
         listgftypes, handler, false);
 
     System.out.printf("--- Stage 2 Restored--- \n");
+    long agesum2 = 0L;
     for (Person<Long> eval2 : firstnv2) {
-      if (null != eval2) {
-        eval2.testOutputAge();
-      }
+      Assert.assertNotNull(eval2);
+      eval2.testOutputAge();
+      agesum2 += eval2.getAge();
     }
     System.out.printf("\n");
+    Assert.assertEquals(agesum1, agesum2);
 
     GeneralComputingService gcsvr = Utils.getGeneralComputingService("sort");
     ValueInfo vinfo = new ValueInfo();
@@ -148,12 +151,19 @@ public class DurableSinglyLinkedListNGSortTest {
         listgftypes, handler2, false);
 
     System.out.printf("--- Stage 3 Sorted--- \n");
+    long agesum3 = 0L;
+    int preage = -1;
     for (Person<Long> eval3 : firstnv3) {
-      if (null != eval3) {
-        eval3.testOutputAge();
+      Assert.assertNotNull(eval3);
+      eval3.testOutputAge();
+      agesum3 += eval3.getAge();
+      if (preage >= 0) {
+        Assert.assertTrue(eval3.getAge() >= preage);
       }
+      preage = eval3.getAge();
     }
     System.out.printf("\n");
+    Assert.assertEquals(agesum2, agesum3);
   }
 
   @Test(enabled = true)
@@ -191,6 +201,7 @@ public class DurableSinglyLinkedListNGSortTest {
 
     pre_nextnv = null;
     Double val;
+    double valsum1 = 0.0;
     for (int i = 0; i < elem_count; ++i) {
       first_elem = null;
       pre_elem = null;
@@ -205,6 +216,7 @@ public class DurableSinglyLinkedListNGSortTest {
         }
         pre_elem = elem;
         System.out.printf("%f ", val);
+        valsum1 += val;
       }
 
       nextnv = DurableSinglyLinkedListFactory.create(m_act, linkedefproxies, linkedgftypes,
false);
@@ -227,13 +239,17 @@ public class DurableSinglyLinkedListNGSortTest {
     Iterator<Double> elemiter = null;
 
     System.out.printf(" --- Stage 2 Restored --- \n");
+    double val2, valsum2 = 0.0;
     while (iter.hasNext()) {
       elemiter = iter.next().iterator();
       while (elemiter.hasNext()) {
-        System.out.printf("%f ", elemiter.next());
+        val2 = elemiter.next();
+        System.out.printf("%f ", val2);
+        valsum2 += val2;
       }
       System.out.printf(" Fetched an item... \n");
     }
+    Assert.assertEquals(valsum1, valsum2, 0.0001);
 
     GeneralComputingService gcsvr = Utils.getGeneralComputingService("sort");
     ValueInfo vinfo = new ValueInfo();
@@ -255,14 +271,22 @@ public class DurableSinglyLinkedListNGSortTest {
     Iterator<Double> elemiter3 = null;
 
     System.out.printf(" --- Stage 3 Sorted --- \n");
+    double val3, valsum3 = 0.0, preval3;
     while (iter3.hasNext()) {
       elemiter3 = iter3.next().iterator();
+      preval3 = 0.0;
       while (elemiter3.hasNext()) {
-        System.out.printf("%f ", elemiter3.next());
+        val3 = elemiter3.next();
+        System.out.printf("%f ", val3);
+        valsum3 += val3;
+        if (preval3 != 0.0) {
+          Assert.assertTrue(val3 >= preval3);
+        }
+        preval3 = val3;
       }
       System.out.printf(" Fetched an item... \n");
     }
-
+    Assert.assertEquals(valsum2, valsum3, 0.0001);
   }
 
 }


Mime
View raw message