All tests passed. (refresh)

Text Expected Actual
test01_basic:
Passed s.getSortKey("sv","abc") abc abc
Passed s.getSortKey("sv","a b c") abc abc
Passed s.getSortKey("fr","TV") tv tv
Text Expected Actual
test02_diacritics:
Passed s.getSortKey("sv","åra") z~ra z~ra
Passed s.getSortKey("en","åra") ara ara
Passed s.getSortKey("sv","Åre") z~re z~re
Passed s.getSortKey("fr","Åre") are are
Passed s.getSortKey("","éüåäö") euaao euaao
Passed s.getSortKey("xyz","éüåäö") euaao euaao
Text Expected Actual
test03_special_characters:
Passed s.getSortKey("de","a.,-b") ab ab
Passed s.getSortKey("","a.,-b") ab ab
Passed s.getSortKey("xx","a.,-b") ab ab
Passed s.getSortKey("xx","a&b") ab ab
Text Expected Actual
test04_missing_pagename:
Passed s.getSortKey("sv")
Passed s.getSortKey("sv","")
Text Expected Actual
test05_bad_language_code:
Passed s.getSortKey(nil,"é.,-b") eb eb
Passed s.getSortKey("","é.,-b") eb eb
Passed s.getSortKey("xx","é.,-b") eb eb
Passed s.getSortKey("xyz","é.,-b") eb eb
Text Expected Actual
test06_numbers_basic:
Passed s.getSortKey("sv","33") ::33 ::33
Passed s.getSortKey("sv","ab33cd") ab::33cd ab::33cd
Text Expected Actual
test07_numbers_with_special_characters:
Passed s.getSortKey("sv","1,2-etandiol") ::12etandiol ::12etandiol
Passed s.getSortKey("sv","1,2,3-propantriol") :::123propantriol :::123propantriol
Text Expected Actual
test08_numbers_multiple_occurances:
Passed s.getSortKey("sv","ab33cd9988ef") ab::33cd::::9988ef ab::33cd::::9988ef
Passed s.getSortKey("sv","ab0033cd09900ef") ab::33cd::::9900ef ab::33cd::::9900ef
Text Expected Actual
test09_dont_mess_up_non_latin:
Passed 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