Untitled
raw download clone
TEXT
views 52
,
size 3050 b
@Test
    fun insertRootCase() {
        // Building expected structure of tree
        expectedTree.root = RedBlackNode(0, value, Color.Black)

         // Making tree using existing methods
        actualTree[0] = value

         assertEquals(expectedTree, actualTree)
    }

     @Test
    fun insertRootLeftCase() {
        // Building expected structure of tree
        expectedTree.root = RedBlackNode(0, value, Color.Black)

         expectedTree.root!!.addLeftSon(-100, value, Color.Red)

         // Making tree using existing methods
        for (key in arrayOf(0, -100))
            actualTree[key] = value

         assertEquals(expectedTree, actualTree)
    }

     @Test
    fun insertRootRightCase() {
        // Building expected structure of tree
        expectedTree.root = RedBlackNode(0, value, Color.Black)

         expectedTree.root!!.addRightSon(100, value, Color.Red)

         // Making tree using existing methods
        for (key in arrayOf(0, 100))
            actualTree[key] = value

         assertEquals(expectedTree, actualTree)
    }

     @Test
    fun insertRootLeftLeftCase() {
        // Building expected structure of tree
        expectedTree.root = RedBlackNode(-100, value, Color.Black)

         expectedTree.root!!.addLeftSon(-200, value, Color.Red)

         expectedTree.root!!.addRightSon(0, value, Color.Red)

         // Making tree using existing methods
        for (key in arrayOf(0, -100, -200))
            actualTree[key] = value

         assertEquals(expectedTree, actualTree)
    }

     @Test
    fun insertRootLeftRightCase() {
        // Building expected structure of tree
        expectedTree.root = RedBlackNode(-50, value, Color.Black)

         expectedTree.root!!.addLeftSon(-100, value, Color.Red)

         expectedTree.root!!.addRightSon(0, value, Color.Red)

         // Making tree using existing methods
        for (key in arrayOf(0, -100, -50))
            actualTree[key] = value

         assertEquals(expectedTree, actualTree)
    }

     @Test
    fun insertRootRightLeftCase() {
        // Building expected structure of tree
        expectedTree.root = RedBlackNode(50, value, Color.Black)

         expectedTree.root!!.addLeftSon(0, value, Color.Red)

         expectedTree.root!!.addRightSon(100, value, Color.Red)

         // Making tree using existing methods
        for (key in arrayOf(0, 100, 50))
            actualTree[key] = value

         assertEquals(expectedTree, actualTree)
    }

     @Test
    fun insertRootRightRightCase() {
        // Building expected structure of tree
        expectedTree.root = RedBlackNode(100, value, Color.Black)

         expectedTree.root!!.addLeftSon(0, value, Color.Red)

         expectedTree.root!!.addRightSon(200, value, Color.Red)

         // Making tree using existing methods
        for (key in arrayOf(0, 100, 200))
            actualTree[key] = value

         assertEquals(expectedTree, actualTree)
    }
close fullscreen
Login or Register to edit or fork this paste. It's free.