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