Refactor chapter recognition tests to run in parallel
This commit is contained in:
parent
3e07100dc2
commit
aa2370b381
@ -2,310 +2,165 @@ package eu.kanade.tachiyomi.data.database
|
|||||||
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
|
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition.parseChapterNumber
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
import org.junit.jupiter.api.BeforeEach
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.parallel.Execution
|
||||||
|
import org.junit.jupiter.api.parallel.ExecutionMode
|
||||||
|
|
||||||
|
@Execution(ExecutionMode.CONCURRENT)
|
||||||
class ChapterRecognitionTest {
|
class ChapterRecognitionTest {
|
||||||
|
|
||||||
private lateinit var manga: Manga
|
|
||||||
private lateinit var chapter: Chapter
|
|
||||||
|
|
||||||
private fun createChapter(name: String): Chapter {
|
|
||||||
chapter = Chapter.create()
|
|
||||||
chapter.name = name
|
|
||||||
return chapter
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createManga(title: String): Manga {
|
|
||||||
manga.title = title
|
|
||||||
return manga
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
fun setup() {
|
|
||||||
manga = Manga.create(0).apply { title = "random" }
|
|
||||||
chapter = Chapter.create()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ch.xx base case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun `ChCaseBase`() {
|
fun `Basic Ch prefix`() {
|
||||||
createManga("Mokushiroku Alice")
|
val manga = createManga("Mokushiroku Alice")
|
||||||
|
|
||||||
createChapter("Mokushiroku Alice Vol.1 Ch.4: Misrepresentation")
|
assertChapter(manga, "Mokushiroku Alice Vol.1 Ch.4: Misrepresentation", 4f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(4f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ch. xx base case but space after period
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun ChCaseBase2() {
|
fun `Basic Ch prefix with space after period`() {
|
||||||
createManga("Mokushiroku Alice")
|
val manga = createManga("Mokushiroku Alice")
|
||||||
|
|
||||||
createChapter("Mokushiroku Alice Vol. 1 Ch. 4: Misrepresentation")
|
assertChapter(manga, "Mokushiroku Alice Vol. 1 Ch. 4: Misrepresentation", 4f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(4f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ch.xx.x base case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun ChCaseDecimal() {
|
fun `Basic Ch prefix with decimal`() {
|
||||||
createManga("Mokushiroku Alice")
|
val manga = createManga("Mokushiroku Alice")
|
||||||
|
|
||||||
createChapter("Mokushiroku Alice Vol.1 Ch.4.1: Misrepresentation")
|
assertChapter(manga, "Mokushiroku Alice Vol.1 Ch.4.1: Misrepresentation", 4.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Mokushiroku Alice Vol.1 Ch.4.4: Misrepresentation", 4.4f)
|
||||||
assertEquals(4.1f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Mokushiroku Alice Vol.1 Ch.4.4: Misrepresentation")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(4.4f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ch.xx.a base case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun ChCaseAlpha() {
|
fun `Basic Ch prefix with alpha postfix`() {
|
||||||
createManga("Mokushiroku Alice")
|
val manga = createManga("Mokushiroku Alice")
|
||||||
|
|
||||||
createChapter("Mokushiroku Alice Vol.1 Ch.4.a: Misrepresentation")
|
assertChapter(manga, "Mokushiroku Alice Vol.1 Ch.4.a: Misrepresentation", 4.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Mokushiroku Alice Vol.1 Ch.4.b: Misrepresentation", 4.2f)
|
||||||
assertEquals(4.1f, chapter.chapter_number)
|
assertChapter(manga, "Mokushiroku Alice Vol.1 Ch.4.extra: Misrepresentation", 4.99f)
|
||||||
|
|
||||||
createChapter("Mokushiroku Alice Vol.1 Ch.4.b: Misrepresentation")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(4.2f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Mokushiroku Alice Vol.1 Ch.4.extra: Misrepresentation")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(4.99f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Name containing one number base case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun OneNumberCaseBase() {
|
fun `Name containing one number`() {
|
||||||
createManga("Bleach")
|
val manga = createManga("Bleach")
|
||||||
|
|
||||||
createChapter("Bleach 567 Down With Snowwhite")
|
assertChapter(manga, "Bleach 567 Down With Snowwhite", 567f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(567f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Name containing one number and decimal case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun OneNumberCaseDecimal() {
|
fun `Name containing one number and decimal`() {
|
||||||
createManga("Bleach")
|
val manga = createManga("Bleach")
|
||||||
|
|
||||||
createChapter("Bleach 567.1 Down With Snowwhite")
|
assertChapter(manga, "Bleach 567.1 Down With Snowwhite", 567.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Bleach 567.4 Down With Snowwhite", 567.4f)
|
||||||
assertEquals(567.1f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Bleach 567.4 Down With Snowwhite")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(567.4f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Name containing one number and alpha case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun OneNumberCaseAlpha() {
|
fun `Name containing one number and alpha`() {
|
||||||
createManga("Bleach")
|
val manga = createManga("Bleach")
|
||||||
|
|
||||||
createChapter("Bleach 567.a Down With Snowwhite")
|
assertChapter(manga, "Bleach 567.a Down With Snowwhite", 567.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Bleach 567.b Down With Snowwhite", 567.2f)
|
||||||
assertEquals(567.1f, chapter.chapter_number)
|
assertChapter(manga, "Bleach 567.extra Down With Snowwhite", 567.99f)
|
||||||
|
|
||||||
createChapter("Bleach 567.b Down With Snowwhite")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(567.2f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Bleach 567.extra Down With Snowwhite")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(567.99f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter containing manga title and number base case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun MangaTitleCaseBase() {
|
fun `Chapter containing manga title and number`() {
|
||||||
createManga("Solanin")
|
val manga = createManga("Solanin")
|
||||||
|
|
||||||
createChapter("Solanin 028 Vol. 2")
|
assertChapter(manga, "Solanin 028 Vol. 2", 28f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(28f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter containing manga title and number decimal case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun MangaTitleCaseDecimal() {
|
fun `Chapter containing manga title and number decimal`() {
|
||||||
createManga("Solanin")
|
val manga = createManga("Solanin")
|
||||||
|
|
||||||
createChapter("Solanin 028.1 Vol. 2")
|
assertChapter(manga, "Solanin 028.1 Vol. 2", 28.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Solanin 028.4 Vol. 2", 28.4f)
|
||||||
assertEquals(28.1f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Solanin 028.4 Vol. 2")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(28.4f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter containing manga title and number alpha case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun MangaTitleCaseAlpha() {
|
fun `Chapter containing manga title and number alpha`() {
|
||||||
createManga("Solanin")
|
val manga = createManga("Solanin")
|
||||||
|
|
||||||
createChapter("Solanin 028.a Vol. 2")
|
assertChapter(manga, "Solanin 028.a Vol. 2", 28.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Solanin 028.b Vol. 2", 28.2f)
|
||||||
assertEquals(28.1f, chapter.chapter_number)
|
assertChapter(manga, "Solanin 028.extra Vol. 2", 28.99f)
|
||||||
|
|
||||||
createChapter("Solanin 028.b Vol. 2")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(28.2f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Solanin 028.extra Vol. 2")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(28.99f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extreme base case
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun ExtremeCaseBase() {
|
fun `Extreme case`() {
|
||||||
createManga("Onepunch-Man")
|
val manga = createManga("Onepunch-Man")
|
||||||
|
|
||||||
createChapter("Onepunch-Man Punch Ver002 028")
|
assertChapter(manga, "Onepunch-Man Punch Ver002 028", 28f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(28f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extreme base case decimal
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun ExtremeCaseDecimal() {
|
fun `Extreme case with decimal`() {
|
||||||
createManga("Onepunch-Man")
|
val manga = createManga("Onepunch-Man")
|
||||||
|
|
||||||
createChapter("Onepunch-Man Punch Ver002 028.1")
|
assertChapter(manga, "Onepunch-Man Punch Ver002 028.1", 28.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Onepunch-Man Punch Ver002 028.4", 28.4f)
|
||||||
assertEquals(28.1f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Onepunch-Man Punch Ver002 028.4")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(28.4f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extreme base case alpha
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun ExtremeCaseAlpha() {
|
fun `Extreme case with alpha`() {
|
||||||
createManga("Onepunch-Man")
|
val manga = createManga("Onepunch-Man")
|
||||||
|
|
||||||
createChapter("Onepunch-Man Punch Ver002 028.a")
|
assertChapter(manga, "Onepunch-Man Punch Ver002 028.a", 28.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Onepunch-Man Punch Ver002 028.b", 28.2f)
|
||||||
assertEquals(28.1f, chapter.chapter_number)
|
assertChapter(manga, "Onepunch-Man Punch Ver002 028.extra", 28.99f)
|
||||||
|
|
||||||
createChapter("Onepunch-Man Punch Ver002 028.b")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(28.2f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Onepunch-Man Punch Ver002 028.extra")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(28.99f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter containing .v2
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun dotV2Case() {
|
fun `Chapter containing dot v2`() {
|
||||||
createChapter("Vol.1 Ch.5v.2: Alones")
|
val manga = createManga("random")
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(5f, chapter.chapter_number)
|
assertChapter(manga, "Vol.1 Ch.5v.2: Alones", 5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check for case with number in manga title
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun numberInMangaTitleCase() {
|
fun `Number in manga title`() {
|
||||||
createManga("Ayame 14")
|
val manga = createManga("Ayame 14")
|
||||||
createChapter("Ayame 14 1 - The summer of 14")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Ayame 14 1 - The summer of 14", 1f)
|
||||||
assertEquals(1f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Case with space between ch. x
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun spaceAfterChapterCase() {
|
fun `Space between ch x`() {
|
||||||
createManga("Mokushiroku Alice")
|
val manga = createManga("Mokushiroku Alice")
|
||||||
createChapter("Mokushiroku Alice Vol.1 Ch. 4: Misrepresentation")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Mokushiroku Alice Vol.1 Ch. 4: Misrepresentation", 4f)
|
||||||
assertEquals(4f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter containing mar(ch)
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun marchInChapterCase() {
|
fun `Chapter title with ch substring`() {
|
||||||
createManga("Ayame 14")
|
val manga = createManga("Ayame 14")
|
||||||
createChapter("Vol.1 Ch.1: March 25 (First Day Cohabiting)")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Vol.1 Ch.1: March 25 (First Day Cohabiting)", 1f)
|
||||||
assertEquals(1f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter containing multiple zeros
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun multipleZerosCase() {
|
fun `Chapter containing multiple zeros`() {
|
||||||
createChapter("Vol.001 Ch.003: Kaguya Doesn't Know Much")
|
val manga = createManga("random")
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(3f, chapter.chapter_number)
|
assertChapter(manga, "Vol.001 Ch.003: Kaguya Doesn't Know Much", 3f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter with version before number
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chapterBeforeNumberCase() {
|
fun `Chapter with version before number`() {
|
||||||
createManga("Onepunch-Man")
|
val manga = createManga("Onepunch-Man")
|
||||||
createChapter("Onepunch-Man Punch Ver002 086 : Creeping Darkness [3]")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Onepunch-Man Punch Ver002 086 : Creeping Darkness [3]", 86f)
|
||||||
assertEquals(86f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Case with version attached to chapter number
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun vAttachedToChapterCase() {
|
fun `Version attached to chapter number`() {
|
||||||
createManga("Ansatsu Kyoushitsu")
|
val manga = createManga("Ansatsu Kyoushitsu")
|
||||||
createChapter("Ansatsu Kyoushitsu 011v002: Assembly Time")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Ansatsu Kyoushitsu 011v002: Assembly Time", 11f)
|
||||||
assertEquals(11f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -313,176 +168,111 @@ class ChapterRecognitionTest {
|
|||||||
* But wait it's not actual the chapter number.
|
* But wait it's not actual the chapter number.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun NumberAfterMangaTitleWithChapterInChapterTitleCase() {
|
fun `Number after manga title with chapter in chapter title case`() {
|
||||||
createChapter("Tokyo ESP 027: Part 002: Chapter 001")
|
val manga = createManga("Tokyo ESP")
|
||||||
createManga("Tokyo ESP")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Tokyo ESP 027: Part 002: Chapter 001", 027f)
|
||||||
assertEquals(027f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* unParsable chapter
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun unParsableCase() {
|
fun `Unparseable chapter`() {
|
||||||
createChapter("Foo")
|
val manga = createManga("random")
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(-1f, chapter.chapter_number)
|
assertChapter(manga, "Foo", -1f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* chapter with time in title
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun timeChapterCase() {
|
fun `Chapter with time in title`() {
|
||||||
createChapter("Fairy Tail 404: 00:00")
|
val manga = createManga("random")
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(404f, chapter.chapter_number)
|
assertChapter(manga, "Fairy Tail 404: 00:00", 404f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* chapter with alpha without dot
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun alphaWithoutDotCase() {
|
fun `Chapter with alpha without dot`() {
|
||||||
createChapter("Asu No Yoichi 19a")
|
val manga = createManga("random")
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(19.1f, chapter.chapter_number)
|
assertChapter(manga, "Asu No Yoichi 19a", 19.1f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter title containing extra and vol
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chapterContainingExtraCase() {
|
fun `Chapter title containing extra and vol`() {
|
||||||
createManga("Fairy Tail")
|
val manga = createManga("Fairy Tail")
|
||||||
|
|
||||||
createChapter("Fairy Tail 404.extravol002")
|
assertChapter(manga, "Fairy Tail 404.extravol002", 404.99f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Fairy Tail 404 extravol002", 404.99f)
|
||||||
assertEquals(404.99f, chapter.chapter_number)
|
assertChapter(manga, "Fairy Tail 404.evol002", 404.5f)
|
||||||
|
|
||||||
createChapter("Fairy Tail 404 extravol002")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(404.99f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Fairy Tail 404.evol002")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(404.5f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter title containing omake (japanese extra) and vol
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chapterContainingOmakeCase() {
|
fun `Chapter title containing omake (japanese extra) and vol`() {
|
||||||
createManga("Fairy Tail")
|
val manga = createManga("Fairy Tail")
|
||||||
|
|
||||||
createChapter("Fairy Tail 404.omakevol002")
|
assertChapter(manga, "Fairy Tail 404.omakevol002", 404.98f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Fairy Tail 404 omakevol002", 404.98f)
|
||||||
assertEquals(404.98f, chapter.chapter_number)
|
assertChapter(manga, "Fairy Tail 404.ovol002", 404.15f)
|
||||||
|
|
||||||
createChapter("Fairy Tail 404 omakevol002")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(404.98f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Fairy Tail 404.ovol002")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(404.15f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter title containing special and vol
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chapterContainingSpecialCase() {
|
fun `Chapter title containing special and vol`() {
|
||||||
createManga("Fairy Tail")
|
val manga = createManga("Fairy Tail")
|
||||||
|
|
||||||
createChapter("Fairy Tail 404.specialvol002")
|
assertChapter(manga, "Fairy Tail 404.specialvol002", 404.97f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Fairy Tail 404 specialvol002", 404.97f)
|
||||||
assertEquals(404.97f, chapter.chapter_number)
|
assertChapter(manga, "Fairy Tail 404.svol002", 404.19f)
|
||||||
|
|
||||||
createChapter("Fairy Tail 404 specialvol002")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(404.97f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Fairy Tail 404.svol002")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(404.19f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter title containing comma's
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chapterContainingCommasCase() {
|
fun `Chapter title containing commas`() {
|
||||||
createManga("One Piece")
|
val manga = createManga("One Piece")
|
||||||
|
|
||||||
createChapter("One Piece 300,a")
|
assertChapter(manga, "One Piece 300,a", 300.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "One Piece Ch,123,extra", 123.99f)
|
||||||
assertEquals(300.1f, chapter.chapter_number)
|
assertChapter(manga, "One Piece the sunny, goes swimming 024,005", 24.005f)
|
||||||
|
|
||||||
createChapter("One Piece Ch,123,extra")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(123.99f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("One Piece the sunny, goes swimming 024,005")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(24.005f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chapter title containing hyphen's
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chapterContainingHyphensCase() {
|
fun `Chapter title containing hyphens`() {
|
||||||
createManga("Solo Leveling")
|
val manga = createManga("Solo Leveling")
|
||||||
|
|
||||||
createChapter("ch 122-a")
|
assertChapter(manga, "ch 122-a", 122.1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
assertChapter(manga, "Solo Leveling Ch.123-extra", 123.99f)
|
||||||
assertEquals(122.1f, chapter.chapter_number)
|
assertChapter(manga, "Solo Leveling, 024-005", 24.005f)
|
||||||
|
assertChapter(manga, "Ch.191-200 Read Online", 191.200f)
|
||||||
createChapter("Solo Leveling Ch.123-extra")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(123.99f, chapter.chapter_number)
|
|
||||||
|
|
||||||
createChapter("Solo Leveling, 024-005")
|
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(24.005f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for chapters containing season
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chapterContainingSeasonCase() {
|
fun `Chapters containing season`() {
|
||||||
createManga("D.I.C.E")
|
val manga = createManga("D.I.C.E")
|
||||||
|
|
||||||
createChapter("D.I.C.E[Season 001] Ep. 007")
|
assertChapter(manga, "D.I.C.E[Season 001] Ep. 007", 7f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(7f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for chapters in format sx - chapter xx
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chapterContainingSeasonCase2() {
|
fun `Chapters in format sx - chapter xx`() {
|
||||||
createManga("The Gamer")
|
val manga = createManga("The Gamer")
|
||||||
|
|
||||||
createChapter("S3 - Chapter 20")
|
assertChapter(manga, "S3 - Chapter 20", 20f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
|
||||||
assertEquals(20f, chapter.chapter_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for chapters ending with s
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun chaptersEndingWithS() {
|
fun `Chapters ending with s`() {
|
||||||
createManga("One Outs")
|
val manga = createManga("One Outs")
|
||||||
|
|
||||||
createChapter("One Outs 001")
|
assertChapter(manga, "One Outs 001", 1f)
|
||||||
ChapterRecognition.parseChapterNumber(chapter, manga)
|
}
|
||||||
assertEquals(1f, chapter.chapter_number)
|
|
||||||
|
private fun assertChapter(manga: Manga, name: String, expected: Float) {
|
||||||
|
val chapter = Chapter.create()
|
||||||
|
chapter.name = name
|
||||||
|
|
||||||
|
parseChapterNumber(chapter, manga)
|
||||||
|
assertEquals(expected, chapter.chapter_number)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createManga(title: String): Manga {
|
||||||
|
val manga = Manga.create(0)
|
||||||
|
manga.title = title
|
||||||
|
return manga
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user