music: add tests for album types
Add tests for Album.Type. Other tests for the music library will be done separately.
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Auxio Project
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.auxio.music
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class AlbumTypeTest {
|
||||
@Test
|
||||
fun albumType_parse_primary() {
|
||||
assertEquals(Album.Type.Album(null), Album.Type.parse(listOf("album")))
|
||||
assertEquals(Album.Type.EP(null), Album.Type.parse(listOf("ep")))
|
||||
assertEquals(Album.Type.Single(null), Album.Type.parse(listOf("single")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun albumType_parse_secondary() {
|
||||
assertEquals(Album.Type.Compilation(null), Album.Type.parse(listOf("album", "compilation")))
|
||||
assertEquals(Album.Type.Soundtrack, Album.Type.parse(listOf("album", "soundtrack")))
|
||||
assertEquals(Album.Type.Mix, Album.Type.parse(listOf("album", "dj-mix")))
|
||||
assertEquals(Album.Type.Mixtape, Album.Type.parse(listOf("album", "mixtape/street")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun albumType_parse_modifiers() {
|
||||
assertEquals(
|
||||
Album.Type.Album(Album.Type.Refinement.LIVE), Album.Type.parse(listOf("album", "live")))
|
||||
assertEquals(
|
||||
Album.Type.Album(Album.Type.Refinement.REMIX),
|
||||
Album.Type.parse(listOf("album", "remix")))
|
||||
assertEquals(
|
||||
Album.Type.EP(Album.Type.Refinement.LIVE), Album.Type.parse(listOf("ep", "live")))
|
||||
assertEquals(
|
||||
Album.Type.EP(Album.Type.Refinement.REMIX), Album.Type.parse(listOf("ep", "remix")))
|
||||
assertEquals(
|
||||
Album.Type.Single(Album.Type.Refinement.LIVE),
|
||||
Album.Type.parse(listOf("single", "live")))
|
||||
assertEquals(
|
||||
Album.Type.Single(Album.Type.Refinement.REMIX),
|
||||
Album.Type.parse(listOf("single", "remix")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun albumType_parse_secondaryModifiers() {
|
||||
assertEquals(
|
||||
Album.Type.Compilation(Album.Type.Refinement.LIVE),
|
||||
Album.Type.parse(listOf("album", "compilation", "live")))
|
||||
assertEquals(
|
||||
Album.Type.Compilation(Album.Type.Refinement.REMIX),
|
||||
Album.Type.parse(listOf("album", "compilation", "remix")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun albumType_parse_orphanedSecondary() {
|
||||
assertEquals(Album.Type.Compilation(null), Album.Type.parse(listOf("compilation")))
|
||||
assertEquals(Album.Type.Soundtrack, Album.Type.parse(listOf("soundtrack")))
|
||||
assertEquals(Album.Type.Mix, Album.Type.parse(listOf("dj-mix")))
|
||||
assertEquals(Album.Type.Mixtape, Album.Type.parse(listOf("mixtape/street")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun albumType_parse_orphanedModifier() {
|
||||
assertEquals(Album.Type.Album(Album.Type.Refinement.LIVE), Album.Type.parse(listOf("live")))
|
||||
assertEquals(
|
||||
Album.Type.Album(Album.Type.Refinement.REMIX), Album.Type.parse(listOf("remix")))
|
||||
}
|
||||
}
|
||||
@@ -23,35 +23,28 @@ import org.junit.Test
|
||||
|
||||
class DateTest {
|
||||
@Test
|
||||
fun date_equals() {
|
||||
assertTrue(
|
||||
requireNotNull(Date.from("2016-08-16T00:01:02")) ==
|
||||
requireNotNull(Date.from("2016-08-16T00:01:02")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_precisionEquals() {
|
||||
fun date_equals_varyingPrecision() {
|
||||
assertTrue(
|
||||
requireNotNull(Date.from("2016-08-16T00:01:02")) !=
|
||||
requireNotNull(Date.from("2016-08-16")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_compareDates() {
|
||||
fun date_compareTo_dates() {
|
||||
val a = requireNotNull(Date.from("2016-08-16T00:01:02"))
|
||||
val b = requireNotNull(Date.from("2016-09-16T00:01:02"))
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_compareTimes() {
|
||||
fun date_compareTo_times() {
|
||||
val a = requireNotNull(Date.from("2016-08-16T00:02:02"))
|
||||
val b = requireNotNull(Date.from("2016-08-16T00:01:02"))
|
||||
assertEquals(1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_comparePrecision() {
|
||||
fun date_compareTo_varyingPrecision() {
|
||||
val a = requireNotNull(Date.from("2016-08-16T00:01:02"))
|
||||
val b = requireNotNull(Date.from("2016-08-16"))
|
||||
assertEquals(
|
||||
@@ -61,77 +54,42 @@ class DateTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromYear() {
|
||||
fun date_from_values() {
|
||||
assertEquals("2016", Date.from(2016).toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromDate() {
|
||||
assertEquals("2016-08-16", Date.from(2016, 8, 16).toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromDatetime() {
|
||||
assertEquals("2016-08-16T00:01Z", Date.from(2016, 8, 16, 0, 1).toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromFormalTimestamp() {
|
||||
assertEquals("2016-08-16T00:01:02Z", Date.from("2016-08-16T00:01:02").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromSpacedTimestamp() {
|
||||
assertEquals("2016-08-16T00:01:02Z", Date.from("2016-08-16 00:01:02").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromDatestamp() {
|
||||
assertEquals(
|
||||
"2016-08-16",
|
||||
Date.from("2016-08-16").toString(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromWeirdDateTimestamp() {
|
||||
assertEquals("2016-08-16T00:01Z", Date.from("2016-08-16T00:01").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromWeirdDatestamp() {
|
||||
assertEquals("2016-08", Date.from("2016-08").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromYearStamp() {
|
||||
assertEquals("2016", Date.from("2016").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromWackTimestamp() {
|
||||
assertEquals("2016-11", Date.from("2016-11-32 25:43:01").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromBustedTimestamp() {
|
||||
assertEquals(null, Date.from("2016-08-16:00:01:02"))
|
||||
assertEquals(null, Date.from(""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromWackYear() {
|
||||
assertEquals(Date.from(0), null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_fromYearDate() {
|
||||
fun date_from_yearDate() {
|
||||
assertEquals("2016-08-16", Date.from(20160816).toString())
|
||||
assertEquals("2016-08-16", Date.from("20160816").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dateRange_fromDates() {
|
||||
fun date_from_timestamp() {
|
||||
assertEquals("2016-08-16T00:01:02Z", Date.from("2016-08-16T00:01:02").toString())
|
||||
assertEquals("2016-08-16T00:01:02Z", Date.from("2016-08-16 00:01:02").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_from_lesserPrecision() {
|
||||
assertEquals("2016", Date.from("2016").toString())
|
||||
assertEquals("2016-08", Date.from("2016-08").toString())
|
||||
assertEquals("2016-08-16", Date.from("2016-08-16").toString())
|
||||
assertEquals("2016-08-16T00:01Z", Date.from("2016-08-16T00:01").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_from_wack() {
|
||||
assertEquals(null, Date.from(0))
|
||||
assertEquals(null, Date.from(""))
|
||||
assertEquals(null, Date.from("2016-08-16:00:01:02"))
|
||||
assertEquals("2016-11", Date.from("2016-11-32 25:43:01").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dateRange_from_correct() {
|
||||
val range =
|
||||
requireNotNull(
|
||||
Date.Range.from(
|
||||
@@ -145,7 +103,7 @@ class DateTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dateRange_fromSingle() {
|
||||
fun dateRange_from_one() {
|
||||
val range =
|
||||
requireNotNull(
|
||||
Date.Range.from(listOf(requireNotNull(Date.from("2016-08-16T00:01:02")))))
|
||||
@@ -154,7 +112,7 @@ class DateTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dateRange_empty() {
|
||||
fun dateRange_from_none() {
|
||||
assertEquals(null, Date.Range.from(listOf()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.oxycblt.auxio.music
|
||||
|
||||
import org.oxycblt.auxio.music.library.Sort
|
||||
import org.oxycblt.auxio.music.storage.MusicDirectories
|
||||
|
||||
interface FakeMusicSettings : MusicSettings {
|
||||
|
||||
Reference in New Issue
Block a user