Indexed Priority Queue Test Algorithm

The Java collections framework is a set of classes and interfaces that implement normally reusable collection data structures. The collections framework provides both interfaces that specify various collections and classes that implement them. To address the need for reusable collection data structures, several independent frameworks were developed, the most used being Doug Lea's collection package, and ObjectSpace Generic collection library (JGL), whose main goal was consistency with the C++ standard Template library (STL).The collections framework was designed and developed chiefly by Joshua Bloch, and was introduced in JDK 1.2.Collection implementations in pre-JDK 1.2 versions of the Java platform included few data structure classes, but make not contain a collections framework. It reused many ideas and classes from Doug Lea's collection package, which was deprecated as a consequence.
/*
 * Copyright (c) 2017 Kotlin Algorithm Club
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.algorithmexamples.datastructures

import org.junit.Assert
import org.junit.Test
import java.util.NoSuchElementException

class IndexedPriorityQueueTest {
    @Test
    fun emptyTest() {
        val pq = IndexedPriorityQueue<Int>(3)
        Assert.assertEquals(0, pq.size)
        Assert.assertTrue(pq.isEmpty())
    }

    @Test(expected= NoSuchElementException::class)
    fun exceptionTest() {
        val pq = IndexedPriorityQueue<Int>(3)
        pq.peek()
    }

    @Test
    fun naiveTest() {
        val pq = IndexedPriorityQueue<Int>(20)
        for (i in 10 downTo 1) {
            pq.insert(20 - i, i)
            Assert.assertEquals(Pair(20 - i, i), pq.peek())
        }
        for (i in 1..10) {
            Assert.assertEquals(Pair(20 - i, i), pq.poll())
        }
    }
}

LANGUAGE:

DARK MODE: