summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/python/vpp_papi/tests')
-rwxr-xr-xsrc/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py31
1 files changed, 30 insertions, 1 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 9ac3e78224c..5221034da6c 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
@@ -66,14 +66,43 @@ class TestDefaults(unittest.TestCase):
def test_defaults(self):
default_type = VPPType('default_type_t',
[['u16', 'mtu', {'default': 1500, 'limit': 0}]])
+ without_default_type = VPPType('without_default_type_t',
+ [['u16', 'mtu']])
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)
+ # distinguish between parameter 0 and parameter not passed
+ b = default_type.pack({'mtu': 0})
+ self.assertEqual(len(b), 2)
+ nt, size = default_type.unpack(b)
+ self.assertEqual(len(b), size)
+ self.assertEqual(nt.mtu, 0)
+
+ # Ensure that basetypes does not inherit default
+ b = without_default_type.pack({})
+ self.assertEqual(len(b), 2)
+ nt, size = default_type.unpack(b)
+ self.assertEqual(len(b), size)
+ self.assertEqual(nt.mtu, 0)
+
+ # default enum type
+ VPPEnumType('vl_api_enum_t', [["ADDRESS_IP4", 0],
+ ["ADDRESS_IP6", 1],
+ {"enumtype": "u32"}])
+
+ default_with_enum = VPPType('default_enum_type_t',
+ [['u16', 'mtu'], ['vl_api_enum_t',
+ 'e', {'default': 1}]])
+
+ b = default_with_enum.pack({})
+ self.assertEqual(len(b), 6)
+ nt, size = default_with_enum.unpack(b)
+ self.assertEqual(len(b), size)
+ self.assertEqual(nt.e, 1)
class TestAddType(unittest.TestCase):