[BAEL-19886] - minor fixes
This commit is contained in:
parent
e2ec34707b
commit
b3c126f76a
|
@ -5,9 +5,9 @@ package com.baeldung.binarytree
|
|||
* Note that this data type is neither immutable nor thread safe.
|
||||
*/
|
||||
class Node(
|
||||
var key: Int,
|
||||
var left: Node? = null,
|
||||
var right: Node? = null) {
|
||||
var key: Int,
|
||||
var left: Node? = null,
|
||||
var right: Node? = null) {
|
||||
|
||||
/**
|
||||
* Return a node with given value. If no such node exists, return null.
|
||||
|
|
|
@ -70,10 +70,8 @@ class NodeTest {
|
|||
|
||||
@Test
|
||||
fun givenDepthTwo_whenPivotAtDepth2_then_Success() {
|
||||
val left =
|
||||
Node(1, Node(0), Node(2))
|
||||
val right =
|
||||
Node(5, Node(4), Node(6))
|
||||
val left = Node(1, Node(0), Node(2))
|
||||
val right = Node(5, Node(4), Node(6))
|
||||
val n = Node(3, left, right)
|
||||
assertEquals(left.left, n.find(0))
|
||||
}
|
||||
|
@ -246,8 +244,7 @@ class NodeTest {
|
|||
*/
|
||||
@Test
|
||||
fun givenTreeDepthOne_whenValueAbsent_thenNoChange() {
|
||||
val n =
|
||||
Node(1, Node(0), Node(2))
|
||||
val n = Node(1, Node(0), Node(2))
|
||||
n.delete(3)
|
||||
assertEquals(1, n.key)
|
||||
assertEquals(2, n.right!!.key)
|
||||
|
@ -285,11 +282,7 @@ class NodeTest {
|
|||
*/
|
||||
@Test
|
||||
fun givenTreeDepthTwo_whenNodeToDeleteHasOneChild_thenChangeTree() {
|
||||
val n = Node(
|
||||
2,
|
||||
Node(0, null, Node(1)),
|
||||
Node(3)
|
||||
)
|
||||
val n = Node(2, Node(0, null, Node(1)), Node(3))
|
||||
n.delete(0)
|
||||
assertEquals(2, n.key)
|
||||
with(n.right!!) {
|
||||
|
@ -306,13 +299,8 @@ class NodeTest {
|
|||
|
||||
@Test
|
||||
fun givenTreeDepthThree_whenNodeToDeleteHasTwoChildren_thenChangeTree() {
|
||||
val l = Node(
|
||||
2,
|
||||
Node(1),
|
||||
Node(5, Node(4), Node(6))
|
||||
)
|
||||
val r =
|
||||
Node(10, Node(9), Node(11))
|
||||
val l = Node(2, Node(1), Node(5, Node(4), Node(6)))
|
||||
val r = Node(10, Node(9), Node(11))
|
||||
val n = Node(8, l, r)
|
||||
n.delete(8)
|
||||
assertEquals(6, n.key)
|
||||
|
|
|
@ -7,7 +7,7 @@ class ArrayTest {
|
|||
|
||||
@Test
|
||||
fun givenArray_whenValidateArrayType_thenComplete () {
|
||||
val ex = com.baeldung.interoperability.ArrayExample()
|
||||
val ex = ArrayExample()
|
||||
val numArray = intArrayOf(1, 2, 3)
|
||||
|
||||
assertEquals(ex.sumValues(numArray), 6)
|
||||
|
@ -15,7 +15,7 @@ class ArrayTest {
|
|||
|
||||
@Test
|
||||
fun givenCustomer_whenGetSuperType_thenComplete() {
|
||||
val instance = com.baeldung.interoperability.Customer::class
|
||||
val instance = Customer::class
|
||||
val supertypes = instance.supertypes
|
||||
|
||||
assertEquals(supertypes[0].toString(), "kotlin.Any")
|
||||
|
@ -23,7 +23,7 @@ class ArrayTest {
|
|||
|
||||
@Test
|
||||
fun givenCustomer_whenGetConstructor_thenComplete() {
|
||||
val instance = com.baeldung.interoperability.Customer::class.java
|
||||
val instance = Customer::class.java
|
||||
val constructors = instance.constructors
|
||||
|
||||
assertEquals(constructors.size, 1)
|
||||
|
@ -31,7 +31,7 @@ class ArrayTest {
|
|||
}
|
||||
|
||||
fun makeReadFile() {
|
||||
val ax = com.baeldung.interoperability.ArrayExample()
|
||||
val ax = ArrayExample()
|
||||
ax.writeList()
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ class CustomerTest {
|
|||
|
||||
@Test
|
||||
fun givenCustomer_whenNameAndLastNameAreAssigned_thenComplete() {
|
||||
val customer = com.baeldung.interoperability.Customer()
|
||||
val customer = Customer()
|
||||
|
||||
// Setter method is being called
|
||||
customer.firstName = "Frodo"
|
||||
|
|
Loading…
Reference in New Issue