concurrentskiplistsubmaptest.java
来自「SRI international 发布的OAA框架软件」· Java 代码 · 共 701 行 · 第 1/2 页
JAVA
701 行
// Map.Entry e3 = map.ceilingEntry(five);
// assertEquals(five, e3.getKey());
//
// Map.Entry e4 = map.ceilingEntry(six);
// assertNull(e4);
//
// }
//
// /**
// * pollFirstEntry returns entries in order
// */
// public void testPollFirstEntry() {
// ConcurrentNavigableMap map = map5();
// Map.Entry e = map.pollFirstEntry();
// assertEquals(one, e.getKey());
// assertEquals("A", e.getValue());
// e = map.pollFirstEntry();
// assertEquals(two, e.getKey());
// map.put(one, "A");
// e = map.pollFirstEntry();
// assertEquals(one, e.getKey());
// assertEquals("A", e.getValue());
// e = map.pollFirstEntry();
// assertEquals(three, e.getKey());
// map.remove(four);
// e = map.pollFirstEntry();
// assertEquals(five, e.getKey());
// try {
// e.setValue("A");
// shouldThrow();
// } catch (Exception ok) {
// }
// e = map.pollFirstEntry();
// assertNull(e);
// }
//
// /**
// * pollLastEntry returns entries in order
// */
// public void testPollLastEntry() {
// ConcurrentNavigableMap map = map5();
// Map.Entry e = map.pollLastEntry();
// assertEquals(five, e.getKey());
// assertEquals("E", e.getValue());
// e = map.pollLastEntry();
// assertEquals(four, e.getKey());
// map.put(five, "E");
// e = map.pollLastEntry();
// assertEquals(five, e.getKey());
// assertEquals("E", e.getValue());
// e = map.pollLastEntry();
// assertEquals(three, e.getKey());
// map.remove(two);
// e = map.pollLastEntry();
// assertEquals(one, e.getKey());
// try {
// e.setValue("E");
// shouldThrow();
// } catch (Exception ok) {
// }
// e = map.pollLastEntry();
// assertNull(e);
// }
//
// /**
// * size returns the correct values
// */
// public void testSize() {
// ConcurrentNavigableMap map = map5();
// ConcurrentNavigableMap empty = map0();
// assertEquals(0, empty.size());
// assertEquals(5, map.size());
// }
//
// /**
// * toString contains toString of elements
// */
// public void testToString() {
// ConcurrentNavigableMap map = map5();
// String s = map.toString();
// for (int i = 1; i <= 5; ++i) {
// assertTrue(s.indexOf(String.valueOf(i)) >= 0);
// }
// }
//
// // Exception tests
//
// /**
// * get(null) of nonempty map throws NPE
// */
// public void testGet_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map5();
// c.get(null);
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
// /**
// * containsKey(null) of nonempty map throws NPE
// */
// public void testContainsKey_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map5();
// c.containsKey(null);
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
// /**
// * containsValue(null) throws NPE
// */
// public void testContainsValue_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map0();
// c.containsValue(null);
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
//
// /**
// * put(null,x) throws NPE
// */
// public void testPut1_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map5();
// c.put(null, "whatever");
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
// /**
// * putIfAbsent(null, x) throws NPE
// */
// public void testPutIfAbsent1_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map5();
// c.putIfAbsent(null, "whatever");
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
// /**
// * replace(null, x) throws NPE
// */
// public void testReplace_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map5();
// c.replace(null, "whatever");
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
// /**
// * replace(null, x, y) throws NPE
// */
// public void testReplaceValue_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map5();
// c.replace(null, one, "whatever");
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
// /**
// * remove(null) throws NPE
// */
// public void testRemove1_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map5();
// c.remove(null);
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
// /**
// * remove(null, x) throws NPE
// */
// public void testRemove2_NullPointerException() {
// try {
// ConcurrentNavigableMap c = map5();
// c.remove(null, "whatever");
// shouldThrow();
// } catch(NullPointerException e){}
// }
//
// /**
// * A deserialized map equals original
// */
// public void testSerialization() {
// ConcurrentNavigableMap q = map5();
//
// try {
// ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
// ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
// out.writeObject(q);
// out.close();
//
// ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
// ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
// ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
// assertEquals(q.size(), r.size());
// assertTrue(q.equals(r));
// assertTrue(r.equals(q));
// } catch(Exception e){
// e.printStackTrace();
// unexpectedException();
// }
// }
//
//
//
// /**
// * subMap returns map with keys in requested range
// */
// public void testSubMapContents() {
// ConcurrentNavigableMap map = map5();
// SortedMap sm = map.subMap(two, four);
// assertEquals(two, sm.firstKey());
// assertEquals(three, sm.lastKey());
// assertEquals(2, sm.size());
// assertFalse(sm.containsKey(one));
// assertTrue(sm.containsKey(two));
// assertTrue(sm.containsKey(three));
// assertFalse(sm.containsKey(four));
// assertFalse(sm.containsKey(five));
// Iterator i = sm.keySet().iterator();
// Object k;
// k = (Integer)(i.next());
// assertEquals(two, k);
// k = (Integer)(i.next());
// assertEquals(three, k);
// assertFalse(i.hasNext());
// Iterator j = sm.keySet().iterator();
// j.next();
// j.remove();
// assertFalse(map.containsKey(two));
// assertEquals(4, map.size());
// assertEquals(1, sm.size());
// assertEquals(three, sm.firstKey());
// assertEquals(three, sm.lastKey());
// assertTrue(sm.remove(three) != null);
// assertTrue(sm.isEmpty());
// assertEquals(3, map.size());
// }
//
// public void testSubMapContents2() {
// ConcurrentNavigableMap map = map5();
// SortedMap sm = map.subMap(two, three);
// assertEquals(1, sm.size());
// assertEquals(two, sm.firstKey());
// assertEquals(two, sm.lastKey());
// assertFalse(sm.containsKey(one));
// assertTrue(sm.containsKey(two));
// assertFalse(sm.containsKey(three));
// assertFalse(sm.containsKey(four));
// assertFalse(sm.containsKey(five));
// Iterator i = sm.keySet().iterator();
// Object k;
// k = (Integer)(i.next());
// assertEquals(two, k);
// assertFalse(i.hasNext());
// Iterator j = sm.keySet().iterator();
// j.next();
// j.remove();
// assertFalse(map.containsKey(two));
// assertEquals(4, map.size());
// assertEquals(0, sm.size());
// assertTrue(sm.isEmpty());
// assertTrue(sm.remove(three) == null);
// assertEquals(4, map.size());
// }
//
// /**
// * headMap returns map with keys in requested range
// */
// public void testHeadMapContents() {
// ConcurrentNavigableMap map = map5();
// SortedMap sm = map.headMap(four);
// assertTrue(sm.containsKey(one));
// assertTrue(sm.containsKey(two));
// assertTrue(sm.containsKey(three));
// assertFalse(sm.containsKey(four));
// assertFalse(sm.containsKey(five));
// Iterator i = sm.keySet().iterator();
// Object k;
// k = (Integer)(i.next());
// assertEquals(one, k);
// k = (Integer)(i.next());
// assertEquals(two, k);
// k = (Integer)(i.next());
// assertEquals(three, k);
// assertFalse(i.hasNext());
// sm.clear();
// assertTrue(sm.isEmpty());
// assertEquals(2, map.size());
// assertEquals(four, map.firstKey());
// }
//
// /**
// * headMap returns map with keys in requested range
// */
// public void testTailMapContents() {
// ConcurrentNavigableMap map = map5();
// SortedMap sm = map.tailMap(two);
// assertFalse(sm.containsKey(one));
// assertTrue(sm.containsKey(two));
// assertTrue(sm.containsKey(three));
// assertTrue(sm.containsKey(four));
// assertTrue(sm.containsKey(five));
// Iterator i = sm.keySet().iterator();
// Object k;
// k = (Integer)(i.next());
// assertEquals(two, k);
// k = (Integer)(i.next());
// assertEquals(three, k);
// k = (Integer)(i.next());
// assertEquals(four, k);
// k = (Integer)(i.next());
// assertEquals(five, k);
// assertFalse(i.hasNext());
//
// Iterator ei = sm.entrySet().iterator();
// Map.Entry e;
// e = (Map.Entry)(ei.next());
// assertEquals(two, e.getKey());
// assertEquals("B", e.getValue());
// e = (Map.Entry)(ei.next());
// assertEquals(three, e.getKey());
// assertEquals("C", e.getValue());
// e = (Map.Entry)(ei.next());
// assertEquals(four, e.getKey());
// assertEquals("D", e.getValue());
// e = (Map.Entry)(ei.next());
// assertEquals(five, e.getKey());
// assertEquals("E", e.getValue());
// assertFalse(i.hasNext());
//
// SortedMap ssm = sm.tailMap(four);
// assertEquals(four, ssm.firstKey());
// assertEquals(five, ssm.lastKey());
// assertTrue(ssm.remove(four) != null);
// assertEquals(1, ssm.size());
// assertEquals(3, sm.size());
// assertEquals(4, map.size());
// }
//
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?