Module:IPAddress/sandbox/testcases
| This is the test cases page for the module Module:IPAddress/sandbox. Results of the test cases. |
-- 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
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.