Modul:URLutil/teszt

A Wikipédiából, a szabad enciklopédiából
Ugrás a navigációhoz Ugrás a kereséshez

Source code project 1171.svg URLutil/teszt[mi ez?] • [dokumentáció: mutat, szerkeszt] • [tesztek: létrehozás]

A teszt futtatásához kattints a vitalap fülre!

 local p = require('Modul:UnitTesztek')
 
function p:test_getAuthority()
self:preprocess_equals('{{#invoke:URLutil|getAuthority| http://eXample.com}}', 'example.com')  
self:preprocess_equals('{{#invoke:URLutil|getAuthority| https://example.net/ppppp }}', 'example.net')  
self:preprocess_equals('{{#invoke:URLutil|getAuthority| ftp://AÖÚd.org:8080/ppppp}}', 'aöúd.org:8080')  
self:preprocess_equals('{{#invoke:URLutil|getAuthority|//127.0.0.1}}', '127.0.0.1')  
self:preprocess_equals('{{#invoke:URLutil|getAuthority|//noTLD}}', '')  
self:preprocess_equals('{{#invoke:URLutil|getAuthority| http://http://example.com:/badPort}}', '')  
end
function p:test_getHost()
self:preprocess_equals('{{#invoke:URLutil|getHost| //EXAMPLE.ORG:8080/ppppp}}', 'example.org')  
self:preprocess_equals('{{#invoke:URLutil|getHost| https://example.net}}', 'example.net')  
self:preprocess_equals('{{#invoke:URLutil|getHost|//127.0.0.1}}', '127.0.0.1')  
self:preprocess_equals('{{#invoke:URLutil|getHost|abc}}', '')  
end
function p:test_getPort()
self:preprocess_equals('{{#invoke:URLutil|getPort| //EXAMPLE.ORG:8080/ppppp}}', '8080')  
self:preprocess_equals('{{#invoke:URLutil|getPort| //example.org:0/ppppp}}', '')  
self:preprocess_equals('{{#invoke:URLutil|getPort| //example.org:/ppppp}}', '')  
end
function p:test_getProtokoll()
self:preprocess_equals('{{#invoke:URLutil|getProtokoll|//aaa}}', '//')  
self:preprocess_equals('{{#invoke:URLutil|getProtokoll|HTTP://aaa}}', 'http://')  
self:preprocess_equals('{{#invoke:URLutil|getProtokoll| https://example.com}}', 'https://')  
self:preprocess_equals('{{#invoke:URLutil|getProtokoll|http://}}', 'http://')  
self:preprocess_equals('{{#invoke:URLutil|getProtokoll|//}}', '//')  
self:preprocess_equals('{{#invoke:URLutil|getProtokoll|http:}}', '')  
self:preprocess_equals('{{#invoke:URLutil|getProtokoll| ://example.net}}', '')  
self:preprocess_equals('{{#invoke:URLutil|getProtokoll| https//example.com}}', '')  
end
function p:test_getTLD()
self:preprocess_equals('{{#invoke:URLutil|getTLD|https://Example.COM}}', 'com')  
self:preprocess_equals('{{#invoke:URLutil|getTLD|//ezsemmi.sehol.nincs/index.php?}}', 'nincs')  
self:preprocess_equals('{{#invoke:URLutil|getTLD|//127.0.0.1}}', '')  
self:preprocess_equals('{{#invoke:URLutil|getTLD|//nowhere/index.php?}}', '')  
self:preprocess_equals('{{#invoke:URLutil|getTLD|example.org}}', '')  
end
function p:test_getTop2domain()
self:preprocess_equals('{{#invoke:URLutil|getTop2domain|https://Example.COM}}', 'example.com')  
self:preprocess_equals('{{#invoke:URLutil|getTop2domain|//ezsemmi.sehol.nincs/index.php?}}', 'sehol.nincs')  
self:preprocess_equals('{{#invoke:URLutil|getTop2domain|//0xff.nowhere/index.php?}}', '0xff.nowhere')  
self:preprocess_equals('{{#invoke:URLutil|getTop2domain|//www.expo.02.ch/index.php?}}', '02.ch')  
self:preprocess_equals('{{#invoke:URLutil|getTop2domain|//127.0.0.1}}', '')  
self:preprocess_equals('{{#invoke:URLutil|getTop2domain|//nowhere/index.php?}}', '')  
end
function p:test_isAuthority()
self:preprocess_equals('{{#invoke:URLutil|isAuthority|sub.example.org:80}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isAuthority|127.0.0.1}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isAuthority|http://example.org}}', '')  
end
function p:test_isDomain()
self:preprocess_equals('{{#invoke:URLutil|isDomain|sub.example.org}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isDomain|127.0.0.1}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isDomain|sub.example.org:80}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isDomain|https://example.net/ppppp}}', '')  
end
function p:test_isHost()
self:preprocess_equals('{{#invoke:URLutil|isHost|sub.example.org}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isHost|127.0.0.1}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isHost|sub.example.org:80}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isHost|http://example.org}}', '')  
end
function p:test_isIP()
self:preprocess_equals('{{#invoke:URLutil|isIP|127.0.0.1}}', '4')  
self:preprocess_equals('{{#invoke:URLutil|isIP|2001:0db8:85a3:08d3:1319:8a2e:0370:7344}}', '6')  
self:preprocess_equals('{{#invoke:URLutil|isIP|Felhasználó}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isIP| }}', '')  
self:preprocess_equals('{{#invoke:URLutil|isIP|987.654.321.0}}', '')  
end
function p:test_isIPv4()
self:preprocess_equals('{{#invoke:URLutil|isIPv4|127.0.0.1}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isIPv4|2001:0db8:85a3:08d3:1319:8a2e:0370:7344}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isIPv4|}}', '')  
end
function p:test_isIPv6()
self:preprocess_equals('{{#invoke:URLutil|isIPv6|127.0.0.1}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isIPv6|2001:0db8:85a3:08d3:1319:8a2e:0370:7344}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isIPv6|Felhasználó}}', '')  
end
function p:test_isHost()
self:preprocess_equals('{{#invoke:URLutil|isMailAddress| ö.gn-fn@example.net }}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isMailAddress|example.net}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isMailAddress|user.gn-fn@}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isMailAddress|foo@bar}}', '')  
end
function p:test_isMailLink()
self:preprocess_equals('{{#invoke:URLutil|isMailLink| mailto:ö.gn-fn@example.net }}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isMailLink| ö.gn-fn@example.net }}', '')  
end
function p:test_isProtocolDialog()
self:preprocess_equals('{{#invoke:URLutil|isProtocolDialog|irc}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolDialog|mailto:}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolDialog|http:}}', '')  
end
function p:test_isProtocolWiki()
self:preprocess_equals('{{#invoke:URLutil|isProtocolWiki|//}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolWiki|http://}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolWiki|http:}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolWiki|https}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolWiki|HTTP}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolWiki|wais}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolWiki|irc}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isProtocolWiki|http//}}', '')  
end
function p:test_isResourceURL()
self:preprocess_equals('{{#invoke:URLutil|isResourceURL| https://example.net/ppppp }}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isResourceURL| gopher://example.net/ppppp }}', '')  
end
function p:test_isSuspiciousURL()
self:preprocess_equals('{{#invoke:URLutil|isSuspiciousURL|1=http://example.com/p[x]=5}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isSuspiciousURL|1=http://example.org/a{{!}}b}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isSuspiciousURL|//127.0.0.1:8080/Ppp}}', '')  
end
function p:test_isUnescapedURL()
self:preprocess_equals('{{#invoke:URLutil|isUnescapedURL|1=http://example.com/p[x]=5}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isUnescapedURL|1=http://example.org/p=5}}', '')  
end
function p:test_isWebURL()
self:preprocess_equals('{{#invoke:URLutil|isWebURL|HTTP://Example.net:80/ppppp}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isWebURL|//127.0.0.1:8080/Ppp}}', '1')  
self:preprocess_equals('{{#invoke:URLutil|isWebURL|http://example.org/ path}}', '')  
self:preprocess_equals('{{#invoke:URLutil|isWebURL|/example.org/path}}', '')  
end
function p:test_wikiEscapeURL()
self:preprocess_equals('{{#invoke:URLutil|wikiEscapeURL|1=http://example.com/p[x]=5}}', 'http://example.com/p[x]=5')
end

return p