Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
t.Errorf("Unexpected value from the function getRawQuery, got '%s', wanted '%s' for '%s'",value,test["expected"],test["test"])
}
}
}
funcTestGenSearchWithOrdering(t*testing.T){
vartests=[]map[string]string{
{
"test":"",
"mode":"2",
"expected":"/search?order=true&sort=2",
},
{
"test":"http://lol.co/?s=why&sort=1",
"mode":"2",
"expected":"/search?order=false&s=why&sort=2",
},
{
"test":"http://lol.co/?s=why&sort=1",
"mode":"1",
"expected":"/search?order=true&s=why&sort=1",
},
{
"test":"http://lol.co/?s=why&sort=1&order=true",
"mode":"1",
"expected":"/search?order=false&s=why&sort=1",
},
{
"test":"http://lol.co/?s=why&sort=1&order=false",
"mode":"1",
"expected":"/search?order=true&s=why&sort=1",
},
{
"test":"http://lol.co/?s=why&sort=1&order=false",
"mode":"2",
"expected":"/search?order=false&s=why&sort=2",
},
{
"test":"http://lol.co/?s=why&sort=1&order=true",
"mode":"2",
"expected":"/search?order=false&s=why&sort=2",
},
}
for_,test:=rangetests{
url,_:=url.Parse(test["test"])
value:=genSearchWithOrdering(url,test["mode"])
ifvalue!=test["expected"]{
t.Errorf("Unexpected value from the function genSearchWithOrdering, got '%s', wanted '%s' for '%s' and '%s'",value,test["expected"],test["test"],test["mode"])
}
}
}
funcTestFlagCode(t*testing.T){
vartests=[]map[string]string{
{
"test":"",
"expected":"und",
},
{
"test":"es",
"expected":"es",
},
{
"test":"lol",
"expected":"lol",
},
{
"test":"fr-fr",
"expected":"fr",
},
{
"test":"fr-lol",
"expected":"lol",
},
{
"test":"ca-es",
"expected":"ca",
},
{
"test":"es-mx",
"expected":"es",
},
}
for_,test:=rangetests{
value:=flagCode(test["test"])
ifvalue!=test["expected"]{
t.Errorf("Unexpected value from the function flagCode, got '%s', wanted '%s' for '%s'",value,test["expected"],test["test"])
t.Errorf("Unexpected value from the function languageName, got '%s', wanted '%s' for '%v'",value,test.Expected,test.TestLang)
}
}
}
funcTestLanguageNameFromCode(t*testing.T){
vartests=[]struct{
TestLangstring
Expectedstring
}{
{
TestLang:"",
Expected:"",
},
{
TestLang:"fr-fr",
Expected:"French (France)",
},
{
TestLang:"ofjd",
Expected:"",
},
{
TestLang:"fr",
Expected:"French",
},
{
TestLang:"es, es-mx",
Expected:"Spanish, Mexican Spanish",
},
}
T:=mockupTemplateT(t)
for_,test:=rangetests{
value:=languageNameFromCode(test.TestLang,T)
ifvalue!=test.Expected{
t.Errorf("Unexpected value from the function languageName, got '%s', wanted '%s' for '%s'",value,test.Expected,test.TestLang)
}
}
}
funcTestFileSize(t*testing.T){
vartests=[]struct{
TestSizeint64
Expectedtemplate.HTML
}{
{
TestSize:0,
Expected:template.HTML("Unknown"),
},
{
TestSize:10,
Expected:template.HTML("10.0 B"),
},
}
T:=mockupTemplateT(t)
for_,test:=rangetests{
value:=fileSize(test.TestSize,T)
ifvalue!=test.Expected{
t.Errorf("Unexpected value from the function languageName, got '%s', wanted '%s' for '%d'",value,test.Expected,test.TestSize)
}
}
}
funcTestLastID(t*testing.T){
vartests=[]struct{
TestTorrents[]models.TorrentJSON
TestURLstring
Expectedint
}{
{
TestTorrents:[]models.TorrentJSON{{ID:3},{ID:1}},
TestURL:"?sort=&order=",
Expected:3,
},
{
TestTorrents:[]models.TorrentJSON{{ID:3},{ID:1}},
TestURL:"?sort=2&order=",
Expected:3,
},
{
TestTorrents:[]models.TorrentJSON{{ID:1},{ID:3}},
TestURL:"?sort=2&order=true",
Expected:3,
},
{
TestTorrents:[]models.TorrentJSON{{ID:1},{ID:3}},
TestURL:"?sort=3&order=true",
Expected:0,
},
{
TestTorrents:[]models.TorrentJSON{},
TestURL:"?sort=2&order=true",
Expected:0,
},
{
TestTorrents:[]models.TorrentJSON{},
TestURL:"?sort=2&order=false",
Expected:0,
},
}
for_,test:=rangetests{
url,_:=url.Parse(test.TestURL)
value:=lastID(url,test.TestTorrents)
ifvalue!=test.Expected{
t.Errorf("Unexpected value from the function languageName, got '%d', wanted '%d' for '%s' and '%v'",value,test.Expected,test.TestURL,test.TestTorrents)
}
}
}
funcTestGetReportDescription(t*testing.T){
vartests=[]struct{
TestDescstring
Expectedstring
}{
{
TestDesc:"",
Expected:"",
},
{
TestDesc:"illegal",
Expected:"Illegal content",
},
{
TestDesc:"spam",
Expected:"Spam / Garbage",
},
{
TestDesc:"wrongcat",
Expected:"Wrong category",
},
{
TestDesc:"dup",
Expected:"Duplicate / Deprecated",
},
{
TestDesc:"illegal_content",
Expected:"Illegal content",
},
{
TestDesc:"spam_garbage",
Expected:"Spam / Garbage",
},
{
TestDesc:"wrong_category",
Expected:"Wrong category",
},
{
TestDesc:"duplicate_deprecated",
Expected:"Duplicate / Deprecated",
},
}
T:=mockupTemplateT(t)
for_,test:=rangetests{
value:=getReportDescription(test.TestDesc,T)
ifvalue!=test.Expected{
t.Errorf("Unexpected value from the function languageName, got '%s', wanted '%s' for '%s'",value,test.Expected,test.TestDesc)
t.Errorf("Unexpected value from the function languageName, got '%s', wanted '%s' for '%d' and '%s' and '%t'",string(value),string(test.Expected),test.TestID,string(test.TestName),test.TestHidden)
}
}
}
funcTestContains(t*testing.T){
vartests=[]struct{
TestArrinterface{}
TestCompstring
Expectedbool
}{
{
TestArr:"kilo",
TestComp:"kilo",
Expected:true,
},
{
TestArr:"kilo",
TestComp:"loki",// Clearly not the same level
Expected:false,
},
{
TestArr:"kilo",
TestComp:"kiloo",
Expected:false,
},
{
TestArr:publicSettings.Language{Code:"kilo"},
TestComp:"kilo",
Expected:true,
},
{
TestArr:publicSettings.Language{Code:"kilo"},
TestComp:"loki",// Clearly not the same level
Expected:false,
},
{
TestArr:publicSettings.Language{Code:"kilo"},
TestComp:"kiloo",
Expected:false,
},
{
TestArr:"kilo",
TestComp:"",
Expected:false,
},
{
TestArr:publicSettings.Language{Code:"kilo"},
TestComp:"",
Expected:false,
},
}
for_,test:=rangetests{
value:=contains(test.TestArr,test.TestComp)
ifvalue!=test.Expected{
t.Errorf("Unexpected value from the function languageName, got '%t', wanted '%t' for '%v' and '%s'",value,test.Expected,test.TestArr,test.TestComp)