Kyaria

TestClass

Jun 26th, 2019
3,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.25 KB | None | 0 0
  1. import org.junit.Test
  2.  
  3. class TestClass {
  4.  
  5.     val compareInts = object : Comparator<Song> {
  6.         override fun compare(a: Song, b: Song): Int = a.bewertung - b.bewertung
  7.     }
  8.  
  9.     val treeTest = SongTreeContainer(
  10.         mutableListOf<Song>(
  11.             Song("Led Zeppelin", "Led Zeppelin", 180, 90),
  12.             Song("Led Zeppelin II", "Led Zeppelin", 147, 80),
  13.             Song("Led Zeppelin III", "Led Zeppelin", 260, 72),
  14.             Song("[Led Zeppelin IV]", "Led Zeppelin", 451, 85)
  15.         ), compareInts
  16.     )
  17.  
  18.     @Test
  19.     fun testPlaytime() {
  20.  
  21.         println("Playtime: ${treeTest.playtime()}\n")
  22.     }
  23.  
  24.     @Test
  25.     fun testSize(){
  26.  
  27.         println("Size: ${treeTest.size()}\n")
  28.     }
  29.  
  30.     @Test
  31.     fun testForEachSong() {
  32.  
  33.         treeTest.forEachSong { println(" ${it.titel}") }
  34.  
  35.         //val listSong = mutableListOf<Song>()
  36.         //treeTest.forEachSong { listSong.add(it) }
  37.     }
  38.  
  39.     @Test
  40.     fun testAddSorted(){
  41.  
  42.         val song4 = Song("[Led Zeppelin IV]", "Led Zeppelin", 451, 85)
  43.         treeTest.addSorted(song4, compareInts)
  44.  
  45.         println("\nPlaytime: ${treeTest.playtime()}\n")
  46.  
  47.         println("Size: ${treeTest.size()}\n")
  48.  
  49.         treeTest.forEachSong { println(" ${it.titel}") }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment