Fara í innihald

Module:Hnit/testcases

Úr Wikipediu, frjálsa alfræðiritinu

Hægt er að búa til leiðbeiningar fyrir þessa skriftu á Module:Hnit/testcases/doc

-- Unit tests for [[Module:Hnit]]. Click talk page to run tests.
local p = require('Module:UnitTests')
 
function p:test_coord()
    self:preprocess_equals_preprocess_many('{{#invoke:Hnit/sandbox|coord|', '}}', 
            '{{#invoke:Hnit|coord|', '}}', {
        {'57|18|22|N|4|27|32|W', '57|18|22|N|4|27|32|W'},
        {'57|18|22|N|4|27|32|V', '57|18|22|N|4|27|32|V'},
        {'57|18|N|4|27|V', '57|18|N|4|27|V'},
        {'57|N|4|V', '57|N|4|V'},
        {'44.112|-87.913', '44.112|-87.913'},
        {'44.117|-87.913|dim:30_region:US-WI_type:landmark|name=Klann Road', '44.117|-87.913|dim:30_region:US-WI_type:landmark|name=Klann Road'},
        {'10.2|-20.3|display=inline', '10.2|-20.3|display=inline'},
        {'55.752222|N|37.615556|E|format=dms', '55.752222|N|37.615556|E|format=dms'},
        {'39.098095|-94.587307|format=dms', '39.098095|-94.587307|format=dms'},
        {'55.752222|N|37.615556|E|format=dec|name=Moscow', '55.752222|N|37.615556|E|format=dec|name=Moscow'},
        {'-20.4|-20.4|name=Test case SW-1c: -20.4d -20.4d (-20.4, -20.4)', '-20.4|-20.4|name=Test case SW-1c: -20.4d -20.4d (-20.4, -20.4)'},
        {'1|2|globe=moon|name=Test case globe= dec', '1|2|globe=moon|name=Test case globe= dec'},
        {'1|2|3|4', '1|2|3|4'},
        {'1|2|3|E|4|5|6|N', '1|2|3|E|4|5|6|N'},
        {'1|2||N|5|6||E|name=Test case DMS blank S', '1|2||N|5|6||E|name=Test case DMS blank S'},
        {' 51 | 02 | 21 |N| 116 | 26 | 34 |W|name=Test case extra blanks', ' 51 | 02 | 21 |N| 116 | 26 | 34 |W|name=Test case extra blanks'},
    }, {stripmarker = 1})
end

function p:test_coord2text()
    self:preprocess_equals_preprocess_many('{{#invoke:Hnit/sandbox|coord2text|', '}}', 
            '{{#invoke:Hnit|coord2text|', '}}', {
            { '{{Hnit/sandbox|57|18|22|N|4|27|32|E|display=inline}}|lat', '{{Hnit|57|18|22|N|4|27|32|E|display=inline}}|lat'},
            { '{{Hnit/sandbox|57|18|22|N|4|27|32|E|display=inline}}|long', '{{Hnit|57|18|22|N|4|27|32|E|display=inline}}|long'},
            { '{{Hnit/sandbox|57|18|22|N|4|27|32|A|display=inline}}|lat', '{{Hnit|57|18|22|N|4|27|32|A|display=inline}}|lat'},
            { '{{Hnit/sandbox|57|18|22|N|4|27|32|A|display=inline}}|long', '{{Hnit|57|18|22|N|4|27|32|A|display=inline}}|long'},
}, {stripmarker = 1})
end

return p