Program: 4243
Project: 4243
Buggy source:
public void testPrefixedBy(){
  PatriciaTrie<String,String> trie=new PatriciaTrie<String,String>(new CharSequenceKeyAnalyzer());
  final String[] keys=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  for (  String key : keys) {
    trie.put(key,key);
  }
  SortedMap<String,String> map;
  Iterator<String> iterator;
  Iterator<Map.Entry<String,String>> entryIterator;
  Map.Entry<String,String> entry;
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(8,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertEquals("String_Node_Str",map.get("String_Node_Str"));
  assertNotNull(trie.get("String_Node_Str"));
  assertNull(map.get("String_Node_Str"));
  assertNull(trie.get("String_Node_Str"));
  assertNull(map.get("String_Node_Str"));
  iterator=map.values().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  assertEquals(4,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertNull(trie.get("String_Node_Str"));
  map.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",trie.get("String_Node_Str"));
  assertEquals(5,map.size());
  assertEquals("String_Node_Str",map.lastKey());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  assertEquals("String_Node_Str",map.remove("String_Node_Str"));
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(2,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  entryIterator=map.entrySet().iterator();
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  assertFalse(entryIterator.hasNext());
  trie.put("String_Node_Str","String_Node_Str");
  assertEquals(3,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  entryIterator=map.entrySet().iterator();
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  assertFalse(entryIterator.hasNext());
  assertEquals("String_Node_Str",trie.remove("String_Node_Str"));
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertEquals(2,map.size());
  entryIterator=map.entrySet().iterator();
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  assertFalse(entryIterator.hasNext());
  assertEquals("String_Node_Str",trie.remove("String_Node_Str"));
  trie.put("String_Node_Str","String_Node_Str");
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(2,map.size());
  assertFalse(map.containsKey("String_Node_Str"));
  assertTrue(map.containsKey("String_Node_Str"));
  assertFalse(map.containsKey("String_Node_Str"));
  iterator=map.values().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(1,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(1,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertFalse(map.isEmpty());
  assertEquals(3,map.size());
  assertEquals("String_Node_Str",trie.remove("String_Node_Str"));
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  iterator=map.keySet().iterator();
  map.put("String_Node_Str","String_Node_Str");
  assertEquals(3,map.size());
  try {
    iterator.next();
    fail("String_Node_Str");
  }
 catch (  ConcurrentModificationException expected) {
  }
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(2,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  map.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertEquals(3,map.size());
  trie.put("String_Node_Str","String_Node_Str");
  assertEquals(3,map.size());
  assertEquals("String_Node_Str",map.remove("String_Node_Str"));
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertEquals(2,map.size());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  assertEquals("String_Node_Str",trie.remove("String_Node_Str"));
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(1,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertTrue(map.isEmpty());
  assertEquals(0,map.size());
  try {
    Object o=map.firstKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  try {
    Object o=map.lastKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  iterator=map.values().iterator();
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertTrue(map.isEmpty());
  assertEquals(0,map.size());
  try {
    Object o=map.firstKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  try {
    Object o=map.lastKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  iterator=map.values().iterator();
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertSame(trie,map);
  map=trie.getPrefixedBy("String_Node_Str");
  assertTrue(map.isEmpty());
  assertEquals(0,map.size());
  try {
    Object o=map.firstKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  try {
    Object o=map.lastKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  iterator=map.values().iterator();
  assertFalse(iterator.hasNext());
}

Fixed version (ground truth):
public void testPrefixedBy(){
  PatriciaTrie<String,String> trie=new PatriciaTrie<String,String>(new CharSequenceKeyAnalyzer());
  final String[] keys=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  for (  String key : keys) {
    trie.put(key,key);
  }
  SortedMap<String,String> map;
  Iterator<String> iterator;
  Iterator<Map.Entry<String,String>> entryIterator;
  Map.Entry<String,String> entry;
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(8,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertEquals("String_Node_Str",map.get("String_Node_Str"));
  assertNotNull(trie.get("String_Node_Str"));
  assertNull(map.get("String_Node_Str"));
  assertNull(trie.get("String_Node_Str"));
  assertNull(map.get("String_Node_Str"));
  iterator=map.values().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  assertEquals(4,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertNull(trie.get("String_Node_Str"));
  map.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",trie.get("String_Node_Str"));
  assertEquals(5,map.size());
  assertEquals("String_Node_Str",map.lastKey());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  assertEquals("String_Node_Str",map.remove("String_Node_Str"));
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(2,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  entryIterator=map.entrySet().iterator();
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  assertFalse(entryIterator.hasNext());
  trie.put("String_Node_Str","String_Node_Str");
  assertEquals(3,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  entryIterator=map.entrySet().iterator();
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  assertFalse(entryIterator.hasNext());
  assertEquals("String_Node_Str",trie.remove("String_Node_Str"));
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertEquals(2,map.size());
  entryIterator=map.entrySet().iterator();
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  entry=entryIterator.next();
  assertEquals("String_Node_Str",entry.getKey());
  assertEquals("String_Node_Str",entry.getValue());
  assertFalse(entryIterator.hasNext());
  assertEquals("String_Node_Str",trie.remove("String_Node_Str"));
  trie.put("String_Node_Str","String_Node_Str");
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(2,map.size());
  assertFalse(map.containsKey("String_Node_Str"));
  assertTrue(map.containsKey("String_Node_Str"));
  assertFalse(map.containsKey("String_Node_Str"));
  iterator=map.values().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(1,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(1,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertFalse(map.isEmpty());
  assertEquals(3,map.size());
  assertEquals("String_Node_Str",trie.remove("String_Node_Str"));
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  iterator=map.keySet().iterator();
  map.put("String_Node_Str","String_Node_Str");
  assertEquals(3,map.size());
  try {
    iterator.next();
    fail("String_Node_Str");
  }
 catch (  ConcurrentModificationException expected) {
  }
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  map=trie.getPrefixedBy("String_Node_Str");
  assertTrue(map.isEmpty());
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(2,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  map.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertEquals(3,map.size());
  trie.put("String_Node_Str","String_Node_Str");
  assertEquals(3,map.size());
  assertEquals("String_Node_Str",map.remove("String_Node_Str"));
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  assertEquals(2,map.size());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  assertEquals("String_Node_Str",trie.remove("String_Node_Str"));
  map=trie.getPrefixedBy("String_Node_Str");
  assertEquals(1,map.size());
  assertEquals("String_Node_Str",map.firstKey());
  assertEquals("String_Node_Str",map.lastKey());
  iterator=map.keySet().iterator();
  assertEquals("String_Node_Str",iterator.next());
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertTrue(map.isEmpty());
  assertEquals(0,map.size());
  try {
    Object o=map.firstKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  try {
    Object o=map.lastKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  iterator=map.values().iterator();
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertTrue(map.isEmpty());
  assertEquals(0,map.size());
  try {
    Object o=map.firstKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  try {
    Object o=map.lastKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  iterator=map.values().iterator();
  assertFalse(iterator.hasNext());
  map=trie.getPrefixedBy("String_Node_Str");
  assertSame(trie,map);
  map=trie.getPrefixedBy("String_Node_Str");
  assertTrue(map.isEmpty());
  assertEquals(0,map.size());
  try {
    Object o=map.firstKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  try {
    Object o=map.lastKey();
    fail("String_Node_Str" + o);
  }
 catch (  NoSuchElementException nsee) {
  }
  iterator=map.values().iterator();
  assertFalse(iterator.hasNext());
}