musikr: move tag tests away from auxio
This commit is contained in:
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Auxio Project
|
||||
* DateTest.kt is part of Auxio.
|
||||
*
|
||||
* 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.musikr.tag
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class DateTest {
|
||||
@Test
|
||||
fun date_equals_varyingPrecision() {
|
||||
assertTrue(
|
||||
requireNotNull(Date.from("2016-08-16T00:01:02")) !=
|
||||
requireNotNull(Date.from("2016-08-16")))
|
||||
}
|
||||
|
||||
@Test
|
||||
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_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_compareTo_varyingPrecision() {
|
||||
val a = requireNotNull(Date.from("2016-08-16T00:01:02"))
|
||||
val b = requireNotNull(Date.from("2016-08-16"))
|
||||
assertEquals(
|
||||
1,
|
||||
a.compareTo(b),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_from_values() {
|
||||
assertEquals("2016", Date.from(2016).toString())
|
||||
assertEquals("2016-08-16", Date.from(2016, 8, 16).toString())
|
||||
assertEquals("2016-08-16T00:01Z", Date.from(2016, 8, 16, 0, 1).toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun date_from_yearDate() {
|
||||
assertEquals("2016-08-16", Date.from(20160816).toString())
|
||||
assertEquals("2016-08-16", Date.from("20160816").toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
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())
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Auxio Project
|
||||
* DiscTest.kt is part of Auxio.
|
||||
*
|
||||
* 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.musikr.tag
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class DiscTest {
|
||||
@Test
|
||||
fun disc_equals_byNum() {
|
||||
val a = Disc(0, null)
|
||||
val b = Disc(0, null)
|
||||
assertEquals(a, b)
|
||||
assertEquals(a.hashCode(), b.hashCode())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun disc_equals_bySubtitle() {
|
||||
val a = Disc(0, "z subtitle")
|
||||
val b = Disc(0, "a subtitle")
|
||||
assertEquals(a, b)
|
||||
assertEquals(a.hashCode(), b.hashCode())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun disc_compareTo_byNum() {
|
||||
val a = Disc(0, null)
|
||||
val b = Disc(1, null)
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun disc_compareTo_bySubtitle() {
|
||||
val a = Disc(0, "z subtitle")
|
||||
val b = Disc(1, "a subtitle")
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
}
|
||||
}
|
||||
@@ -1,437 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Auxio Project
|
||||
* NameTest.kt is part of Auxio.
|
||||
*
|
||||
* 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.musikr.tag
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Test
|
||||
|
||||
class NameTest {
|
||||
@Test
|
||||
fun name_simple_withoutPunct() {
|
||||
val name = Name.Known.SimpleFactory.parse("Loveless", null)
|
||||
assertEquals("Loveless", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("L", name.thumb)
|
||||
val only = name.sortTokens.single()
|
||||
assertEquals("Loveless", only.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, only.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_simple_withPunct() {
|
||||
val name = Name.Known.SimpleFactory.parse("alt-J", null)
|
||||
assertEquals("alt-J", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("A", name.thumb)
|
||||
val only = name.sortTokens.single()
|
||||
assertEquals("altJ", only.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, only.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_simple_oopsAllPunct() {
|
||||
val name = Name.Known.SimpleFactory.parse("!!!", null)
|
||||
assertEquals("!!!", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("!", name.thumb)
|
||||
val only = name.sortTokens.single()
|
||||
assertEquals("!!!", only.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, only.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_simple_spacedPunct() {
|
||||
val name = Name.Known.SimpleFactory.parse("& Yet & Yet", null)
|
||||
assertEquals("& Yet & Yet", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("Y", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Yet Yet", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_simple_withSort() {
|
||||
val name = Name.Known.SimpleFactory.parse("The Smile", "Smile")
|
||||
assertEquals("The Smile", name.raw)
|
||||
assertEquals("Smile", name.sort)
|
||||
assertEquals("S", name.thumb)
|
||||
val only = name.sortTokens.single()
|
||||
assertEquals("Smile", only.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, only.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withoutArticle_withoutNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("Loveless", null)
|
||||
assertEquals("Loveless", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("L", name.thumb)
|
||||
val only = name.sortTokens.single()
|
||||
assertEquals("Loveless", only.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, only.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withoutArticle_withSpacedStartNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("15 Step", null)
|
||||
assertEquals("15 Step", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("#", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("15", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, first.type)
|
||||
val second = name.sortTokens[1]
|
||||
assertEquals("Step", second.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, second.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withoutArticle_withPackedStartNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("23Kid", null)
|
||||
assertEquals("23Kid", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("#", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("23", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, first.type)
|
||||
val second = name.sortTokens[1]
|
||||
assertEquals("Kid", second.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, second.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withoutArticle_withSpacedMiddleNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("Foo 1 2 Bar", null)
|
||||
assertEquals("Foo 1 2 Bar", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("F", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Foo", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
val second = name.sortTokens[1]
|
||||
assertEquals("1", second.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, second.type)
|
||||
val third = name.sortTokens[2]
|
||||
assertEquals(" ", third.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, third.type)
|
||||
val fourth = name.sortTokens[3]
|
||||
assertEquals("2", fourth.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, fourth.type)
|
||||
val fifth = name.sortTokens[4]
|
||||
assertEquals("Bar", fifth.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, fifth.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withoutArticle_withPackedMiddleNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("Foo12Bar", null)
|
||||
assertEquals("Foo12Bar", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("F", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Foo", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
val second = name.sortTokens[1]
|
||||
assertEquals("12", second.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, second.type)
|
||||
val third = name.sortTokens[2]
|
||||
assertEquals("Bar", third.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, third.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withoutArticle_withSpacedEndNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("Foo 1", null)
|
||||
assertEquals("Foo 1", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("F", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Foo", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
val second = name.sortTokens[1]
|
||||
assertEquals("1", second.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, second.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withoutArticle_withPackedEndNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("Error404", null)
|
||||
assertEquals("Error404", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("E", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Error", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
val second = name.sortTokens[1]
|
||||
assertEquals("404", second.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, second.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withThe_withoutNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("The National Anthem", null)
|
||||
assertEquals("The National Anthem", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("N", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("National Anthem", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withAn_withoutNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("An Eagle in Your Mind", null)
|
||||
assertEquals("An Eagle in Your Mind", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("E", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Eagle in Your Mind", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_withA_withoutNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("A Song For Our Fathers", null)
|
||||
assertEquals("A Song For Our Fathers", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("S", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Song For Our Fathers", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withPunct_withoutArticle_withoutNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("alt-J", null)
|
||||
assertEquals("alt-J", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("A", name.thumb)
|
||||
val only = name.sortTokens.single()
|
||||
assertEquals("altJ", only.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, only.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_oopsAllPunct_withoutArticle_withoutNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("!!!", null)
|
||||
assertEquals("!!!", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("!", name.thumb)
|
||||
val only = name.sortTokens.single()
|
||||
assertEquals("!!!", only.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, only.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withoutPunct_shortArticle_withNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("the 1", null)
|
||||
assertEquals("the 1", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("#", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("1", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, first.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_spacedPunct_withoutArticle_withoutNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("& Yet & Yet", null)
|
||||
assertEquals("& Yet & Yet", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("Y", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Yet Yet", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withPunct_withoutArticle_withNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("Design : 2 : 3", null)
|
||||
assertEquals("Design : 2 : 3", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("D", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("Design", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, first.type)
|
||||
val second = name.sortTokens[1]
|
||||
assertEquals("2", second.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, second.type)
|
||||
val third = name.sortTokens[2]
|
||||
assertEquals(" ", third.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, third.type)
|
||||
val fourth = name.sortTokens[3]
|
||||
assertEquals("3", fourth.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, fourth.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_oopsAllPunct_withoutArticle_oopsAllNumerics() {
|
||||
val name = Name.Known.IntelligentFactory.parse("2 + 2 = 5", null)
|
||||
assertEquals("2 + 2 = 5", name.raw)
|
||||
assertEquals(null, name.sort)
|
||||
assertEquals("#", name.thumb)
|
||||
val first = name.sortTokens[0]
|
||||
assertEquals("2", first.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, first.type)
|
||||
val second = name.sortTokens[1]
|
||||
assertEquals(" ", second.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, second.type)
|
||||
val third = name.sortTokens[2]
|
||||
assertEquals("2", third.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, third.type)
|
||||
val fourth = name.sortTokens[3]
|
||||
assertEquals(" ", fourth.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, fourth.type)
|
||||
val fifth = name.sortTokens[4]
|
||||
assertEquals("5", fifth.collationKey.sourceString)
|
||||
assertEquals(Token.Type.NUMERIC, fifth.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_intelligent_withSort() {
|
||||
val name = Name.Known.IntelligentFactory.parse("The Smile", "Smile")
|
||||
assertEquals("The Smile", name.raw)
|
||||
assertEquals("Smile", name.sort)
|
||||
assertEquals("S", name.thumb)
|
||||
val only = name.sortTokens.single()
|
||||
assertEquals("Smile", only.collationKey.sourceString)
|
||||
assertEquals(Token.Type.LEXICOGRAPHIC, only.type)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_equals_simple() {
|
||||
val a = Name.Known.SimpleFactory.parse("The Same", "Same")
|
||||
val b = Name.Known.SimpleFactory.parse("The Same", "Same")
|
||||
assertEquals(a, b)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_equals_differentSort() {
|
||||
val a = Name.Known.SimpleFactory.parse("The Same", "Same")
|
||||
val b = Name.Known.SimpleFactory.parse("The Same", null)
|
||||
assertNotEquals(a, b)
|
||||
assertNotEquals(a.hashCode(), b.hashCode())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_equals_intelligent_differentTokens() {
|
||||
val a = Name.Known.IntelligentFactory.parse("The Same", "Same")
|
||||
val b = Name.Known.IntelligentFactory.parse("Same", "Same")
|
||||
assertNotEquals(a, b)
|
||||
assertNotEquals(a.hashCode(), b.hashCode())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_simple_withoutSort_withoutArticle_withoutNumeric() {
|
||||
val a = Name.Known.SimpleFactory.parse("A", null)
|
||||
val b = Name.Known.SimpleFactory.parse("B", null)
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_simple_withoutSort_withArticle_withoutNumeric() {
|
||||
val a = Name.Known.SimpleFactory.parse("A Brain in a Bottle", null)
|
||||
val b = Name.Known.SimpleFactory.parse("Acid Rain", null)
|
||||
val c = Name.Known.SimpleFactory.parse("Boralis / Contrastellar", null)
|
||||
val d = Name.Known.SimpleFactory.parse("Breathe In", null)
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
assertEquals(-1, a.compareTo(c))
|
||||
assertEquals(-1, a.compareTo(d))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_simple_withSort_withoutArticle_withNumeric() {
|
||||
val a = Name.Known.SimpleFactory.parse("15 Step", null)
|
||||
val b = Name.Known.SimpleFactory.parse("128 Harps", null)
|
||||
val c = Name.Known.SimpleFactory.parse("1969", null)
|
||||
assertEquals(1, a.compareTo(b))
|
||||
assertEquals(-1, a.compareTo(c))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_simple_withPartialSort() {
|
||||
val a = Name.Known.SimpleFactory.parse("A", "C")
|
||||
val b = Name.Known.SimpleFactory.parse("B", null)
|
||||
assertEquals(1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_simple_withSort() {
|
||||
val a = Name.Known.SimpleFactory.parse("D", "A")
|
||||
val b = Name.Known.SimpleFactory.parse("C", "B")
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_intelligent_withoutSort_withoutArticle_withoutNumeric() {
|
||||
val a = Name.Known.IntelligentFactory.parse("A", null)
|
||||
val b = Name.Known.IntelligentFactory.parse("B", null)
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_intelligent_withoutSort_withArticle_withoutNumeric() {
|
||||
val a = Name.Known.IntelligentFactory.parse("A Brain in a Bottle", null)
|
||||
val b = Name.Known.IntelligentFactory.parse("Acid Rain", null)
|
||||
val c = Name.Known.IntelligentFactory.parse("Boralis / Contrastellar", null)
|
||||
val d = Name.Known.IntelligentFactory.parse("Breathe In", null)
|
||||
assertEquals(1, a.compareTo(b))
|
||||
assertEquals(1, a.compareTo(c))
|
||||
assertEquals(-1, a.compareTo(d))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_intelligent_withoutSort_withoutArticle_withNumeric() {
|
||||
val a = Name.Known.IntelligentFactory.parse("15 Step", null)
|
||||
val b = Name.Known.IntelligentFactory.parse("128 Harps", null)
|
||||
val c = Name.Known.IntelligentFactory.parse("1969", null)
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
assertEquals(-1, b.compareTo(c))
|
||||
assertEquals(-2, a.compareTo(c))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_intelligent_withPartialSort_withoutArticle_withoutNumeric() {
|
||||
val a = Name.Known.SimpleFactory.parse("A", "C")
|
||||
val b = Name.Known.SimpleFactory.parse("B", null)
|
||||
assertEquals(1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_intelligent_withSort_withoutArticle_withoutNumeric() {
|
||||
val a = Name.Known.IntelligentFactory.parse("D", "A")
|
||||
val b = Name.Known.IntelligentFactory.parse("C", "B")
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_unknown() {
|
||||
val a = Name.Unknown(0)
|
||||
assertEquals("?", a.thumb)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun name_compareTo_mixed() {
|
||||
val a = Name.Unknown(0)
|
||||
val b = Name.Known.IntelligentFactory.parse("A", null)
|
||||
assertEquals(-1, a.compareTo(b))
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Auxio Project
|
||||
* ReleaseTypeTest.kt is part of Auxio.
|
||||
*
|
||||
* 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.musikr.tag
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class ReleaseTypeTest {
|
||||
@Test
|
||||
fun releaseType_parse_primary() {
|
||||
assertEquals(ReleaseType.Album(null), ReleaseType.parse(listOf("album")))
|
||||
assertEquals(ReleaseType.EP(null), ReleaseType.parse(listOf("ep")))
|
||||
assertEquals(ReleaseType.Single(null), ReleaseType.parse(listOf("single")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun releaseType_parse_secondary() {
|
||||
assertEquals(
|
||||
ReleaseType.Compilation(null), ReleaseType.parse(listOf("album", "compilation")))
|
||||
assertEquals(ReleaseType.Soundtrack, ReleaseType.parse(listOf("album", "soundtrack")))
|
||||
assertEquals(ReleaseType.Mix, ReleaseType.parse(listOf("album", "dj-mix")))
|
||||
assertEquals(ReleaseType.Mixtape, ReleaseType.parse(listOf("album", "mixtape/street")))
|
||||
assertEquals(ReleaseType.Demo, ReleaseType.parse(listOf("album", "demo")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun releaseType_parse_modifiers() {
|
||||
assertEquals(
|
||||
ReleaseType.Album(ReleaseType.Refinement.LIVE),
|
||||
ReleaseType.parse(listOf("album", "live")))
|
||||
assertEquals(
|
||||
ReleaseType.Album(ReleaseType.Refinement.REMIX),
|
||||
ReleaseType.parse(listOf("album", "remix")))
|
||||
assertEquals(
|
||||
ReleaseType.EP(ReleaseType.Refinement.LIVE), ReleaseType.parse(listOf("ep", "live")))
|
||||
assertEquals(
|
||||
ReleaseType.EP(ReleaseType.Refinement.REMIX), ReleaseType.parse(listOf("ep", "remix")))
|
||||
assertEquals(
|
||||
ReleaseType.Single(ReleaseType.Refinement.LIVE),
|
||||
ReleaseType.parse(listOf("single", "live")))
|
||||
assertEquals(
|
||||
ReleaseType.Single(ReleaseType.Refinement.REMIX),
|
||||
ReleaseType.parse(listOf("single", "remix")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun releaseType_parse_secondaryModifiers() {
|
||||
assertEquals(
|
||||
ReleaseType.Compilation(ReleaseType.Refinement.LIVE),
|
||||
ReleaseType.parse(listOf("album", "compilation", "live")))
|
||||
assertEquals(
|
||||
ReleaseType.Compilation(ReleaseType.Refinement.REMIX),
|
||||
ReleaseType.parse(listOf("album", "compilation", "remix")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun releaseType_parse_orphanedSecondary() {
|
||||
assertEquals(ReleaseType.Compilation(null), ReleaseType.parse(listOf("compilation")))
|
||||
assertEquals(ReleaseType.Soundtrack, ReleaseType.parse(listOf("soundtrack")))
|
||||
assertEquals(ReleaseType.Mix, ReleaseType.parse(listOf("dj-mix")))
|
||||
assertEquals(ReleaseType.Mixtape, ReleaseType.parse(listOf("mixtape/street")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun releaseType_parse_orphanedModifier() {
|
||||
assertEquals(
|
||||
ReleaseType.Album(ReleaseType.Refinement.LIVE), ReleaseType.parse(listOf("live")))
|
||||
assertEquals(
|
||||
ReleaseType.Album(ReleaseType.Refinement.REMIX), ReleaseType.parse(listOf("remix")))
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Auxio Project
|
||||
* SeparatorsTest.kt is part of Auxio.
|
||||
*
|
||||
* 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.musikr.tag.interpret
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class SeparatorsTest {
|
||||
@Test
|
||||
fun separators_split_withString_withSingleChar() {
|
||||
assertEquals(listOf("a", "b", "c"), Separators.from(",").split(listOf("a,b,c")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun separators_split_withMultiple_withSingleChar() {
|
||||
assertEquals(listOf("a,b", "c", "d"), Separators.from(",").split(listOf("a,b", "c", "d")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun separators_split_withString_withMultipleChar() {
|
||||
assertEquals(
|
||||
listOf("a", "b", "c", "d", "e", "f"),
|
||||
Separators.from(",;/+&").split(listOf("a,b;c/d+e&f")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun separators_split_withList_withMultipleChar() {
|
||||
assertEquals(
|
||||
listOf("a,b;c/d", "e&f"), Separators.from(",;/+&").split(listOf("a,b;c/d", "e&f")))
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Auxio Project
|
||||
* TagUtilTest.kt is part of Auxio.
|
||||
*
|
||||
* 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.musikr.tag.parse
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.oxycblt.musikr.tag.util.correctWhitespace
|
||||
import org.oxycblt.musikr.tag.util.parseId3GenreNames
|
||||
import org.oxycblt.musikr.tag.util.parseId3v2PositionField
|
||||
import org.oxycblt.musikr.tag.util.parseVorbisPositionField
|
||||
import org.oxycblt.musikr.tag.util.splitEscaped
|
||||
|
||||
class TagUtilTest {
|
||||
@Test
|
||||
fun splitEscaped_correct() {
|
||||
assertEquals(listOf("a", "b", "c"), "a,b,c".splitEscaped { it == ',' })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun splitEscaped_escaped() {
|
||||
assertEquals(listOf("a,b", "c"), "a\\,b,c".splitEscaped { it == ',' })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun splitEscaped_whitespace() {
|
||||
assertEquals(listOf("a ", " b", " c ", " "), "a , b, c , ".splitEscaped { it == ',' })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun splitEscaped_escapedWhitespace() {
|
||||
assertEquals(listOf("a , b", " c ", " "), ("a \\, b, c , ".splitEscaped { it == ',' }))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun correctWhitespace_stringCorrect() {
|
||||
assertEquals(
|
||||
"asymptotic self-improvement",
|
||||
" asymptotic self-improvement ".correctWhitespace(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun correctWhitespace_stringOopsAllWhitespace() {
|
||||
assertEquals(null, "".correctWhitespace())
|
||||
assertEquals(null, " ".correctWhitespace())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun correctWhitespace_listCorrect() {
|
||||
assertEquals(
|
||||
listOf("asymptotic self-improvement", "daemons never stop", "tcp phagocyte"),
|
||||
listOf(" asymptotic self-improvement ", " daemons never stop", "tcp phagocyte")
|
||||
.correctWhitespace(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun correctWhitespace_listOopsAllWhitespace() {
|
||||
assertEquals(
|
||||
listOf("tcp phagocyte"), listOf(" ", "", " tcp phagocyte").correctWhitespace())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseId3v2PositionField_correct() {
|
||||
assertEquals(16, "16/32".parseId3v2PositionField())
|
||||
assertEquals(16, "16".parseId3v2PositionField())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseId3v2PositionField_zeroed() {
|
||||
assertEquals(null, "0".parseId3v2PositionField())
|
||||
assertEquals(0, "0/32".parseId3v2PositionField())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseId3v2PositionField_wack() {
|
||||
assertEquals(16, "16/".parseId3v2PositionField())
|
||||
assertEquals(null, "a".parseId3v2PositionField())
|
||||
assertEquals(null, "a/b".parseId3v2PositionField())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseVorbisPositionField_correct() {
|
||||
assertEquals(16, parseVorbisPositionField("16", "32"))
|
||||
assertEquals(16, parseVorbisPositionField("16", null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseVorbisPositionField_zeroed() {
|
||||
assertEquals(null, parseVorbisPositionField("0", null))
|
||||
assertEquals(0, parseVorbisPositionField("0", "32"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseVorbisPositionField_wack() {
|
||||
assertEquals(null, parseVorbisPositionField("a", null))
|
||||
assertEquals(null, parseVorbisPositionField("a", "b"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseId3v2Genre_multi() {
|
||||
assertEquals(
|
||||
listOf("Post-Rock", "Shoegaze", "Glitch"),
|
||||
listOf("Post-Rock", "Shoegaze", "Glitch").parseId3GenreNames())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseId3v2Genre_multiId3v1() {
|
||||
assertEquals(
|
||||
listOf("Post-Rock", "Shoegaze", "Glitch"),
|
||||
listOf("176", "178", "Glitch").parseId3GenreNames())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseId3v2Genre_wackId3() {
|
||||
assertEquals(null, listOf("2941").parseId3GenreNames())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseId3v2Genre_singleId3v23() {
|
||||
assertEquals(
|
||||
listOf("Post-Rock", "Shoegaze", "Remix", "Cover", "Glitch"),
|
||||
listOf("(176)(178)(RX)(CR)Glitch").parseId3GenreNames())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parsId3v2Genre_singleId3v1() {
|
||||
assertEquals(listOf("Post-Rock"), listOf("176").parseId3GenreNames())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user