[geary/wip/181-special-folder-dupes: 4/7] Fix pathological FolderPath.is_equal() case, add unit test



commit e1fd9daa83817eb3b6fca57fcec18f8572e10acb
Author: Michael Gratton <mike vee net>
Date:   Mon Jan 14 18:03:47 2019 +1100

    Fix pathological FolderPath.is_equal() case, add unit test

 src/engine/api/geary-folder-path.vala       | 2 +-
 test/engine/api/geary-folder-path-test.vala | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/engine/api/geary-folder-path.vala b/src/engine/api/geary-folder-path.vala
index 4f01d168..a33ade74 100644
--- a/src/engine/api/geary-folder-path.vala
+++ b/src/engine/api/geary-folder-path.vala
@@ -207,7 +207,7 @@ public class Geary.FolderPath :
 
         FolderPath? a = this;
         FolderPath? b = other;
-        while (a != null && b != null) {
+        while (a != null || b != null) {
             if (a == b) {
                 return true;
             }
diff --git a/test/engine/api/geary-folder-path-test.vala b/test/engine/api/geary-folder-path-test.vala
index c1c16643..18db7308 100644
--- a/test/engine/api/geary-folder-path-test.vala
+++ b/test/engine/api/geary-folder-path-test.vala
@@ -134,6 +134,12 @@ public class Geary.FolderPathTest : TestCase {
             .equal_to(this.root.get_child("test2").get_child("test")),
             "Disjoint parents"
         );
+
+        assert_false(
+            this.root.get_child("test").equal_to(
+                this.root.get_child("").get_child("test")),
+            "Pathological case"
+        );
     }
 
     public void path_hash() throws GLib.Error {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]