Home / Class/ IntPriorityQueueTest Class — netty Architecture

IntPriorityQueueTest Class — netty Architecture

Architecture documentation for the IntPriorityQueueTest class in IntPriorityQueueTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  b98c03f4_3d86_02c0_747b_f06548c0b7f8["IntPriorityQueueTest"]
  4431aa84_71a0_5dbf_5c12_a8b9883f0e5a["IntPriorityQueueTest.java"]
  b98c03f4_3d86_02c0_747b_f06548c0b7f8 -->|defined in| 4431aa84_71a0_5dbf_5c12_a8b9883f0e5a
  bde847fb_ca99_87e2_4023_231ba622ff71["mustThrowWhenAddingNoValue()"]
  b98c03f4_3d86_02c0_747b_f06548c0b7f8 -->|method| bde847fb_ca99_87e2_4023_231ba622ff71
  482daf96_c62c_6b37_292d_b6731c492ef0["mustReturnValuesInOrder()"]
  b98c03f4_3d86_02c0_747b_f06548c0b7f8 -->|method| 482daf96_c62c_6b37_292d_b6731c492ef0
  89f6a9d6_bc48_ad3d_e415_1df61344bffb["internalRemoveOfAllElements()"]
  b98c03f4_3d86_02c0_747b_f06548c0b7f8 -->|method| 89f6a9d6_bc48_ad3d_e415_1df61344bffb
  6c4df1af_563d_d8f2_1d74_4bad1954288a["internalRemoveMustPreserveOrder()"]
  b98c03f4_3d86_02c0_747b_f06548c0b7f8 -->|method| 6c4df1af_563d_d8f2_1d74_4bad1954288a
  240a079a_b8a2_00cf_38cd_edf512e57b1c["mustSupportDuplicateValues()"]
  b98c03f4_3d86_02c0_747b_f06548c0b7f8 -->|method| 240a079a_b8a2_00cf_38cd_edf512e57b1c

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/IntPriorityQueueTest.java lines 29–147

class IntPriorityQueueTest {
    @Test
    public void mustThrowWhenAddingNoValue() {
        final IntPriorityQueue pq = new IntPriorityQueue();
        assertThrows(IllegalArgumentException.class, new Executable() {
            @Override
            public void execute() {
                pq.offer(IntPriorityQueue.NO_VALUE);
            }
        });
    }

    @Test
    public void mustReturnValuesInOrder() {
        ThreadLocalRandom tlr = ThreadLocalRandom.current();
        int initialValues = tlr.nextInt(5, 30);
        ArrayList<Integer> values = new ArrayList<Integer>();
        for (int i = 0; i < initialValues; i++) {
            values.add(tlr.nextInt(0, Integer.MAX_VALUE));
        }
        IntPriorityQueue pq = new IntPriorityQueue();
        assertTrue(pq.isEmpty());
        for (Integer value : values) {
            pq.offer(value);
        }
        Collections.sort(values);
        int valuesToRemove = initialValues / 2;
        ListIterator<Integer> itr = values.listIterator();
        for (int i = 0; i < valuesToRemove; i++) {
            assertTrue(itr.hasNext());
            assertThat(pq.poll()).isEqualTo(itr.next());
            itr.remove();
        }
        int moreValues = tlr.nextInt(5, 30);
        for (int i = 0; i < moreValues; i++) {
            int value = tlr.nextInt(0, Integer.MAX_VALUE);
            pq.offer(value);
            values.add(value);
        }
        Collections.sort(values);
        itr = values.listIterator();
        while (itr.hasNext()) {
            assertThat(pq.poll()).isEqualTo(itr.next());
        }
        assertTrue(pq.isEmpty());
        assertThat(pq.poll()).isEqualTo(IntPriorityQueue.NO_VALUE);
    }

    @Test
    public void internalRemoveOfAllElements() {
        ThreadLocalRandom tlr = ThreadLocalRandom.current();
        int initialValues = tlr.nextInt(5, 30);
        ArrayList<Integer> values = new ArrayList<Integer>();
        IntPriorityQueue pq = new IntPriorityQueue();
        for (int i = 0; i < initialValues; i++) {
            int value = tlr.nextInt(0, Integer.MAX_VALUE);
            pq.offer(value);
            values.add(value);
        }
        for (Integer value : values) {
            pq.remove(value);
        }
        assertTrue(pq.isEmpty());
        assertThat(pq.poll()).isEqualTo(IntPriorityQueue.NO_VALUE);
    }

    @Test
    public void internalRemoveMustPreserveOrder() {
        ThreadLocalRandom tlr = ThreadLocalRandom.current();
        int initialValues = tlr.nextInt(1, 30);
        ArrayList<Integer> values = new ArrayList<Integer>();
        IntPriorityQueue pq = new IntPriorityQueue();
        for (int i = 0; i < initialValues; i++) {
            int value = tlr.nextInt(0, Integer.MAX_VALUE);
            pq.offer(value);
            values.add(value);
        }

        Integer toRemove = values.get(values.size() / 2);
        values.remove(toRemove);
        pq.remove(toRemove);

Frequently Asked Questions

What is the IntPriorityQueueTest class?
IntPriorityQueueTest is a class in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/IntPriorityQueueTest.java.
Where is IntPriorityQueueTest defined?
IntPriorityQueueTest is defined in buffer/src/test/java/io/netty/buffer/IntPriorityQueueTest.java at line 29.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free