package main import ( "testing" "github.com/andreyvit/diff" ) func Test(t *testing.T) { m := newMediaElementWithParent("Misfits - S02E03 - EN FORCED") result := "Misfits - S02E03 EN FORCED" if m.Path() != result { t.Error("Expected " + result + ", got " + m.Path()) } } func TestExamples(t *testing.T) { // list of strings with expected output examples := [][]string{ {"Speak.No.Evil.2024.German.EAC3.DL.1080p.BluRay.x265-VECTOR.nfo", "Speak No Evil (2024) DE 1080p x265.nfo"}, {"Speak.No.Evil.2024.German.EAC3.DL.1080p.BluRay.x265-VECTOR/Speak.No.Evil.2024.nfo", "Speak.No.Evil.2024.German.EAC3.DL.1080p.BluRay.x265-VECTOR/Speak No Evil (2024) DE 1080p x265.nfo"}, {"Speak.No.Evil.2024.nfo", "Speak No Evil (2024).nfo"}, {"Miracles.from.Heaven.2016.1080p.BluRay.X264-AMIABLE/Miracles.from.Heaven.2016.1080p.BluRay.X264-AMIABLE.mkv", "Miracles.from.Heaven.2016.1080p.BluRay.X264-AMIABLE/Miracles from Heaven (2016) 1080p x264.mkv"}, {"Level_16_2018_1080p_BluRay_H264_AAC/Level.16.2018.1080p.BluRay.H264.AAC.mp4", "Level_16_2018_1080p_BluRay_H264_AAC/Level 16 (2018) 1080p x264.mp4"}, {"Scorpion.S02E24.Duell.der.Genies.GERMAN.5.1.DL.AC3.1080p.WEB-DL.x264-TvR/tvr-scorpion-s02e24-1080p.mkv", "Scorpion.S02E24.Duell.der.Genies.GERMAN.5.1.DL.AC3.1080p.WEB-DL.x264-TvR/Scorpion - S02E24 - Duell der Genies DE 1080p x264.mkv"}, } for _, example := range examples { element := newMediaElementWithParent(example[0]) if expected, got := example[1], element.Path(); expected != got { t.Errorf("Result not expected for %s:\n%v", example[0], diff.LineDiff(expected, got)) } } }