[jsword-devel] [JIRA] Created: (JS-183) Comparison of TreeKeys can lead to false positives

Martin Denham (JIRA) jira at crosswire.org
Mon Mar 21 13:53:11 MST 2011


Comparison of TreeKeys can lead to false positives
--------------------------------------------------

                 Key: JS-183
                 URL: http://www.crosswire.org/bugs/browse/JS-183
             Project: JSword
          Issue Type: Bug
          Components: o.c.jsword.passage
    Affects Versions: 1.6.1
         Environment: All
            Reporter: Martin Denham
            Assignee: DM Smith


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);


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jsword-devel mailing list