diff options
Diffstat (limited to 'src/vpp-api/python/vpp_papi/tests')
-rwxr-xr-x | src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py b/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py index ec7334712ab..74a0a62c021 100755 --- a/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py +++ b/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py @@ -9,6 +9,7 @@ import logging import sys from ipaddress import * + class TestLimits(unittest.TestCase): def test_limit(self): limited_type = VPPType('limited_type_t', @@ -16,14 +17,27 @@ class TestLimits(unittest.TestCase): unlimited_type = VPPType('limited_type_t', [['string', 'name']]) - - b = limited_type.pack({'name':'foobar'}) + b = limited_type.pack({'name': 'foobar'}) self.assertEqual(len(b), 10) - b = unlimited_type.pack({'name':'foobar'}) + b = unlimited_type.pack({'name': 'foobar'}) self.assertEqual(len(b), 10) with self.assertRaises(VPPSerializerValueError): - b = limited_type.pack({'name':'foobar'*3}) + b = limited_type.pack({'name': 'foobar'*3}) + + +class TestDefaults(unittest.TestCase): + def test_defaults(self): + default_type = VPPType('default_type_t', + [['u16', 'mtu', {'default': 1500, 'limit': 0}]]) + + b = default_type.pack({}) + self.assertEqual(len(b), 2) + + nt, size = default_type.unpack(b) + self.assertEqual(len(b), size) + self.assertEqual(nt.mtu, 1500) + class TestAddType(unittest.TestCase): |