Uploaded image for project: 'JSword'
  1. JSword
  2. JS-183

Comparison of TreeKeys can lead to false positives

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.6.1
    • Fix Version/s: None
    • Component/s: o.c.jsword.passage
    • Labels:
      None
    • Environment:

      All

      Description

      It could be that TreeKey comparison should also compare parents because some books like Pilgrim's Progress can have keys with identical names but different parents.

      Here is a junit
      Book book = getBook("Pilgrim");

      // flatten and cache all the keys
      List<Key> cachedKeyList = new ArrayList<Key>();
      for (Key key : book.getGlobalKeyList())

      { cachedKeyList.add(key); }

      // get Part II/First Stage key
      Key partIIFirstStage = cachedKeyList.get(20);
      assertEquals("wrong key", "THE FIRST STAGE", partIIFirstStage.getName()); // these 2 tests pass fine
      assertEquals("wrong key", "PART II", partIIFirstStage.getParent().getName()); // they just clarify which key we have

      // now try to find the above key in our cached list of keys but the wrong key is returned
      int indexOfKey = cachedKeyList.indexOf(partIIFirstStage);
      // this test fails because Part I/First Stage is returned instead of Part II/First Stage
      assertEquals("Wrong index", 20, indexOfKey);

        Attachments

          Activity

            People

            • Assignee:
              dmsmith DM Smith
              Reporter:
              mjdenham Martin Denham
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: