'Pack and unpack a bunch of match entries'

def test_match_pack_unpack(self):

    for (nxm_name, nxm_type) in nx._nxm_name_to_type.items():
        nxm_class = nx._nxm_type_to_class[nxm_type]
        mask = None
        if issubclass(nxm_class, nx._nxm_numeric_entry):
            value = 10
            mask = 15
        elif issubclass(nxm_class, nx._nxm_raw):
            value = 'aabb'
        elif issubclass(nxm_class, nx._nxm_ipv6):
            import pox.lib.addresses as addresses
            value = 'ff02::/126'
        elif issubclass(nxm_class, nx._nxm_ip):
            value = IPAddr('192.168.56.0')
            mask = IPAddr('255.255.255.0')
        elif issubclass(nxm_class, nx._nxm_ether):
            value = EthAddr('01:02:03:04:05:06')
        else:
            self.fail(('Unsupported    NXM    type    for    ' + nxm_name))
        if (not issubclass(nxm_class, nx._nxm_maskable)):
            mask = None
        original = nxm_class(value, mask)
        original_packed = original.pack()
        (offset, unoriginal) = nx.nxm_entry.unpack_new(original_packed, 0)
        self.assertEqual(offset, len(original_packed), ("Didn't    unpack    entire    entry    " + nxm_name))
        unoriginal_packed = unoriginal.pack()
        self.assertEqual(original, unoriginal, ('Pack/Unpack    failed    for    ' + nxm_name))
