Kyaria icon

TestClass

Kyaria | PRO | 06/26/19 06:04:50 AM UTC | 0 ⭐ | 11540 👁️ | Never ⏰ | []
Kotlin |

1.25 KB

|

None

|

0 👍

/

0 👎

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

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎