summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/tests
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-04-23 17:11:01 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-04-29 12:07:02 +0000
commit9ac113815511f3ce37b56a1331d6491fc36f7db5 (patch)
tree574f66ce291ee75de2545a051be77a11bbaa43e2 /src/vpp-api/python/vpp_papi/tests
parentde146e5d5f7e919b423feeff3159c4ecd564c353 (diff)
API: Add support for limits to language.
string name [limit = 64]; Meta-data to do argument validation. Change-Id: I1f3e0f09b2d5285224399413d25206f77bd3f4b1 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vpp-api/python/vpp_papi/tests')
-rwxr-xr-xsrc/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py17
1 files changed, 16 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 4fbda2a01af..ec7334712ab 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
@@ -3,12 +3,27 @@
import unittest
from vpp_papi.vpp_serializer import VPPType, VPPEnumType
from vpp_papi.vpp_serializer import VPPUnionType, VPPMessage
-from vpp_papi.vpp_serializer import VPPTypeAlias
+from vpp_papi.vpp_serializer import VPPTypeAlias, VPPSerializerValueError
from socket import inet_pton, AF_INET, AF_INET6
import logging
import sys
from ipaddress import *
+class TestLimits(unittest.TestCase):
+ def test_limit(self):
+ limited_type = VPPType('limited_type_t',
+ [['string', 'name', {'limit': 16}]])
+ unlimited_type = VPPType('limited_type_t',
+ [['string', 'name']])
+
+
+ b = limited_type.pack({'name':'foobar'})
+ self.assertEqual(len(b), 10)
+ b = unlimited_type.pack({'name':'foobar'})
+ self.assertEqual(len(b), 10)
+
+ with self.assertRaises(VPPSerializerValueError):
+ b = limited_type.pack({'name':'foobar'*3})
class TestAddType(unittest.TestCase):