Modul:sort/test
Hoppa till navigering
Hoppa till sök
All tests passed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey("sv","abc") | abc | abc |
![]() |
s.getSortKey("sv","a b c") | abc | abc |
![]() |
s.getSortKey("fr","TV") | tv | tv |
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey("sv","åra") | z~ra | z~ra |
![]() |
s.getSortKey("en","åra") | ara | ara |
![]() |
s.getSortKey("sv","Åre") | z~re | z~re |
![]() |
s.getSortKey("fr","Åre") | are | are |
![]() |
s.getSortKey("","éüåäö") | euaao | euaao |
![]() |
s.getSortKey("xyz","éüåäö") | euaao | euaao |
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey("de","a.,-b") | ab | ab |
![]() |
s.getSortKey("","a.,-b") | ab | ab |
![]() |
s.getSortKey("xx","a.,-b") | ab | ab |
![]() |
s.getSortKey("xx","a&b") | ab | ab |
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey("sv") | ||
![]() |
s.getSortKey("sv","") |
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey(nil,"é.,-b") | eb | eb |
![]() |
s.getSortKey("","é.,-b") | eb | eb |
![]() |
s.getSortKey("xx","é.,-b") | eb | eb |
![]() |
s.getSortKey("xyz","é.,-b") | eb | eb |
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey("sv","33") | ::33 | ::33 |
![]() |
s.getSortKey("sv","ab33cd") | ab::33cd | ab::33cd |
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey("sv","1,2-etandiol") | ::12etandiol | ::12etandiol |
![]() |
s.getSortKey("sv","1,2,3-propantriol") | :::123propantriol | :::123propantriol |
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey("sv","ab33cd9988ef") | ab::33cd::::9988ef | ab::33cd::::9988ef |
![]() |
s.getSortKey("sv","ab0033cd09900ef") | ab::33cd::::9900ef | ab::33cd::::9900ef |
Text | Expected | Actual | |
---|---|---|---|
![]() |
s.getSortKey("zh", "中世紀") | 中世紀 | 中世紀 |
local t = require('Modul:UnitTests')
local mut = require('Modul:sort')
function t:test01_basic()
self:equals('s.getSortKey("sv","abc")', mut.getSortKey("sv","abc"), "abc")
self:equals('s.getSortKey("sv","a b c")', mut.getSortKey("sv","a b c"), "abc")
self:equals('s.getSortKey("fr","TV")', mut.getSortKey("fr","TV"), "tv")
end
function t:test02_diacritics()
self:equals('s.getSortKey("sv","åra")', mut.getSortKey("sv","åra"), "z~ra")
self:equals('s.getSortKey("en","åra")', mut.getSortKey("en","åra"), "ara")
self:equals('s.getSortKey("sv","Åre")', mut.getSortKey("sv","Åre"), "z~re")
self:equals('s.getSortKey("fr","Åre")', mut.getSortKey("fr","Åre"), "are")
self:equals('s.getSortKey("","éüåäö")', mut.getSortKey("","éüåäö"), "euaao")
self:equals('s.getSortKey("xyz","éüåäö")', mut.getSortKey("xyz","éüåäö"), "euaao")
end
function t:test03_special_characters()
self:equals('s.getSortKey("de","a.,-b")', mut.getSortKey("de","a.,-b"), "ab")
self:equals('s.getSortKey("","a.,-b")', mut.getSortKey("","a.,-b"), "ab")
self:equals('s.getSortKey("xx","a.,-b")', mut.getSortKey("xx","a.,-b"), "ab")
self:equals('s.getSortKey("xx","a&b")', mut.getSortKey("xx","a&b"), "ab")
end
function t:test04_missing_pagename()
self:equals('s.getSortKey("sv")', mut.getSortKey("sv"), "")
self:equals('s.getSortKey("sv","")', mut.getSortKey("sv",""), "")
end
function t:test05_bad_language_code()
self:equals('s.getSortKey(nil,"é.,-b")', mut.getSortKey(nil,"é.,-b"), "eb")
self:equals('s.getSortKey("","é.,-b")', mut.getSortKey(nil,"é.,-b"), "eb")
self:equals('s.getSortKey("xx","é.,-b")', mut.getSortKey(nil,"é.,-b"), "eb")
self:equals('s.getSortKey("xyz","é.,-b")', mut.getSortKey(nil,"é.,-b"), "eb")
end
function t:test06_numbers_basic()
self:equals('s.getSortKey("sv","33")', mut.getSortKey("sv","33"), "::33")
self:equals('s.getSortKey("sv","ab33cd")', mut.getSortKey("sv","ab33cd"), "ab::33cd")
end
function t:test07_numbers_with_special_characters()
self:equals('s.getSortKey("sv","1,2-etandiol")', mut.getSortKey("sv","1,2-etandiol"), "::12etandiol")
self:equals('s.getSortKey("sv","1,2,3-propantriol")', mut.getSortKey("sv","1,2,3-propantriol"), ":::123propantriol")
end
function t:test08_numbers_multiple_occurances()
self:equals('s.getSortKey("sv","ab33cd9988ef")', mut.getSortKey("sv","ab33cd9988ef"), "ab::33cd::::9988ef")
self:equals('s.getSortKey("sv","ab0033cd09900ef")', mut.getSortKey("sv","ab0033cd09900ef"), "ab::33cd::::9900ef")
end
function t:test09_dont_mess_up_non_latin()
self:equals('s.getSortKey("zh", "中世紀")', mut.getSortKey("zh", "中世紀"), "中世紀")
end
return t