Jump to content

Module:IPAddress/sandbox/testcases

විකිපීඩියා වෙතින්
-- Unit tests for [[Module:IPAddress/sandbox]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_isIp()
    self:preprocess_equals_many('{{#invoke:IPAddress/sandbox|isIp|', '}}', {
        {'200.200.200.200', '4'},
        {' 200.200.200.200', '4'},
        {'200.200.200.200 ', '4'},
        {'200.200.256.200', ''},
        {'200.200.200.200.', ''},
        {'200.200.200', ''},
        {'200.200.200.2d0', ''},
        {'0.0.0.0', '4'},
        {'00.00.00.00', '4'}, -- leading zeroes are accepted for 0 only
        {'100.100.020.100', ''}, -- leading zeroes for other numbers are not accepted (decimal or octal?)
        {'255.255.255.255', '4'},
        {'-1.0.0.0', ''},
        {'200000000000000000000000000000000000000000000000000000000000000000000000000000.200.200.200', ''},
        {'00000000000005.10.10.10', ''},
        {'00AB:0002:3008:8CFD:00AB:0002:3008:8CFD', '6'}, -- full length
        {'00ab:0002:3008:8cfd:00ab:0002:3008:8cfd', '6'}, -- lowercase
        {'00aB:0002:3008:8cFd:00Ab:0002:3008:8cfD', '6'}, -- mixed case
        {'00AB:00002:3008:8CFD:00AB:0002:3008:8CFD', '6'}, -- accept leading zeroes
        {'00AB:10002:3008:8CFD:00AB:0002:3008:8CFD', ''}, -- at most 4 digits per segment
        {':0002:3008:8CFD:00AB:0002:3008:8CFD', '6'}, -- accept single : at the start (this is, invalid, in strict terms)
        {'00AB:0002:3008:8CFD:00AB:0002:3008:', '6'}, -- accept single : at the end (this is, invalid, in strict terms)
        {'AB:02:3008:8CFD:AB:02:3008:8CFD', '6'}, -- abbreviated
        {'AB:02:3008:8CFD:AB:02:3008:8CFD:02', ''}, -- too long
        {'AB:02:3008:8CFD::02:3008:8CFD', '6'}, -- correct use of ::
        {'AB:02:3008:8CFD::02:3008:8CFD:02', ''}, -- too long
        {'AB:02:3008:8CFD::02::8CFD', ''}, -- can't have two ::s
        {'GB:02:3008:8CFD:AB:02:3008:8CFD', ''}, -- Invalid character G
        {'::', '6'}, -- unassigned IPv6 address
        {'::1', '6'}, -- loopback IPv6 address
        {'0::', '6'}, -- another name for unassigned IPv6 address
        {'0::0', '6'}, -- another name for unassigned IPv6 address
        {'2:::3', ''}, -- illegal: three colons
    })
end

return p
"https://si.wikipedia.org/w/index.php?title=Module:IPAddress/sandbox/testcases&oldid=613577" වෙතින් සම්ප්‍රවේශනය කෙරිණි