import org.junit.Test
class TestClass {
val compareInts = object : Comparator<Song> {
override fun compare(a: Song, b: Song): Int = a.bewertung - b.bewertung
}
val treeTest = SongTreeContainer(
mutableListOf<Song>(
Song("Led Zeppelin", "Led Zeppelin", 180, 90),
Song("Led Zeppelin II", "Led Zeppelin", 147, 80),
Song("Led Zeppelin III", "Led Zeppelin", 260, 72),
Song("[Led Zeppelin IV]", "Led Zeppelin", 451, 85)
), compareInts
)
@Test
fun testPlaytime() {
println("Playtime: ${treeTest.playtime()}\n")
}
@Test
fun testSize(){
println("Size: ${treeTest.size()}\n")
}
@Test
fun testForEachSong() {
treeTest.forEachSong { println(" ${it.titel}") }
//val listSong = mutableListOf<Song>()
//treeTest.forEachSong { listSong.add(it) }
}
@Test
fun testAddSorted(){
val song4 = Song("[Led Zeppelin IV]", "Led Zeppelin", 451, 85)
treeTest.addSorted(song4, compareInts)
println("\nPlaytime: ${treeTest.playtime()}\n")
println("Size: ${treeTest.size()}\n")
treeTest.forEachSong { println(" ${it.titel}") }
}
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎