=Socket Fallback Module Tests=

Copyright (c) 2008-2010, David P. D. Moss. All rights reserved.

{{{

>>> from netaddr.fbsocket import *

}}}

IPv6 '::' compression algorithm tests.

{{{

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, '0:0:0:0:0:0:0:0'))
'::'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, '0:0:0:0:0:0:0:A'))
'::a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, 'A:0:0:0:0:0:0:0'))
'a::'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, 'A:0:A:0:0:0:0:0'))
'a:0:a::'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, 'A:0:0:0:0:0:0:A'))
'a::a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, '0:A:0:0:0:0:0:A'))
'0:a::a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, 'A:0:A:0:0:0:0:A'))
'a:0:a::a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, '0:0:0:A:0:0:0:A'))
'::a:0:0:0:a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, '0:0:0:0:A:0:0:A'))
'::a:0:0:a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, 'A:0:0:0:0:A:0:A'))
'a::a:0:a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, 'A:0:0:A:0:0:A:0'))
'a::a:0:0:a:0'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, 'A:0:A:0:A:0:A:0'))
'a:0:a:0:a:0:a:0'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, '0:A:0:A:0:A:0:A'))
'0:a:0:a:0:a:0:a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, '1080:0:0:0:8:800:200C:417A'))
'1080::8:800:200c:417a'

>>> inet_ntop(AF_INET6, inet_pton(AF_INET6, 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210'))
'fedc:ba98:7654:3210:fedc:ba98:7654:3210'

}}}

IPv4 failure tests

{{{

>>> inet_ntoa(1)
Traceback (most recent call last):
...
TypeError: string type expected, not <class 'int'>


>>> inet_ntoa('\x00')
Traceback (most recent call last):
...
ValueError: invalid length of packed IP address string

>>> inet_aton('0x0')
b'\x00\x00\x00\x00'

>>> inet_aton('010')
b'\x08\x00\x00\x00'

}}}

IPv6 failure tests.

{{{

>>> inet_pton(AF_INET6, '::0x07f')
Traceback (most recent call last):
...
ValueError: illegal IP address string '::0x07f'

}}}
