public void testentrysetiteratornext() {
   smallsortedmap<integer, integer> map = smallsortedmap.newinstancefortest(3);
   for (int i = 0; i < 6; i++) {
     assertnull(map.put(i, i + 1));
   }
   iterator<map.entry<integer, integer>> it = map.entryset().iterator();
   for (int i = 0; i < 6; i++) {
     asserttrue(it.hasnext());
     map.entry<integer, integer> entry = it.next();
     assertequals(new integer(i), entry.getkey());
     assertequals(new integer(i + 1), entry.getvalue());
   }
   assertfalse(it.hasnext());
 }
 public void testmapentrymodification() {
   smallsortedmap<integer, integer> map = smallsortedmap.newinstancefortest(3);
   for (int i = 0; i < 6; i++) {
     assertnull(map.put(i, i + 1));
   }
   iterator<map.entry<integer, integer>> it = map.entryset().iterator();
   for (int i = 0; i < 6; i++) {
     map.entry<integer, integer> entry = it.next();
     entry.setvalue(i + 23);
   }
   for (int i = 0; i < 6; i++) {
     assertequals(new integer(i + 23), map.get(i));
   }
 }
 public void testgetarrayentryandoverflowentries() {
   smallsortedmap<integer, integer> map = smallsortedmap.newinstancefortest(3);
   for (int i = 0; i < 6; i++) {
     assertnull(map.put(i, i + 1));
   }
   assertequals(3, map.getnumarrayentries());
   for (int i = 0; i < 3; i++) {
     map.entry<integer, integer> entry = map.getarrayentryat(i);
     assertequals(new integer(i), entry.getkey());
     assertequals(new integer(i + 1), entry.getvalue());
   }
   iterator<map.entry<integer, integer>> it = map.getoverflowentries().iterator();
   for (int i = 3; i < 6; i++) {
     asserttrue(it.hasnext());
     map.entry<integer, integer> entry = it.next();
     assertequals(new integer(i), entry.getkey());
     assertequals(new integer(i + 1), entry.getvalue());
   }
   assertfalse(it.hasnext());
 }
 @override
 public boolean equals(object o) {
   if (!(o instanceof map.entry)) return false;
   map.entry e = (map.entry) o;
   return eq(key, e.getkey()) && eq(value, e.getvalue());
 }
  public void testmakeimmutable() {
    smallsortedmap<integer, integer> map = smallsortedmap.newinstancefortest(3);
    for (int i = 0; i < 6; i++) {
      assertnull(map.put(i, i + 1));
    }
    map.makeimmutable();
    assertequals(new integer(1), map.get(0));
    assertequals(6, map.size());

    try {
      map.put(23, 23);
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    map<integer, integer> other = new hashmap<integer, integer>();
    other.put(23, 23);
    try {
      map.putall(other);
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    try {
      map.remove(0);
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    try {
      map.clear();
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    set<map.entry<integer, integer>> entryset = map.entryset();
    try {
      entryset.clear();
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    iterator<map.entry<integer, integer>> it = entryset.iterator();
    while (it.hasnext()) {
      map.entry<integer, integer> entry = it.next();
      try {
        entry.setvalue(0);
        fail("expected unsupportedoperationexception");
      } catch (unsupportedoperationexception expected) {
      }
      try {
        it.remove();
        fail("expected unsupportedoperationexception");
      } catch (unsupportedoperationexception expected) {
      }
    }

    set<integer> keyset = map.keyset();
    try {
      keyset.clear();
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    iterator<integer> keys = keyset.iterator();
    while (keys.hasnext()) {
      integer key = keys.next();
      try {
        keyset.remove(key);
        fail("expected unsupportedoperationexception");
      } catch (unsupportedoperationexception expected) {
      }
      try {
        keys.remove();
        fail("expected unsupportedoperationexception");
      } catch (unsupportedoperationexception expected) {
      }
    }
  }