Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com>
---
 ryu/tests/unit/controller/test_controller.py | 36 +++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/ryu/tests/unit/controller/test_controller.py 
b/ryu/tests/unit/controller/test_controller.py
index 27a2bce..a94e7b4 100644
--- a/ryu/tests/unit/controller/test_controller.py
+++ b/ryu/tests/unit/controller/test_controller.py
@@ -24,9 +24,11 @@ import json
 import os
 import sys
 import warnings
-import unittest
 import logging
 import random
+import unittest
+
+from nose.tools import eq_, raises
 
 from ryu.base import app_manager  # To suppress cyclic import
 from ryu.controller import controller
@@ -39,6 +41,38 @@ from ryu.ofproto import ofproto_v1_0_parser
 LOG = logging.getLogger('test_controller')
 
 
+class TestUtils(unittest.TestCase):
+    """
+    Test cases for utilities defined in controller module.
+    """
+
+    def test_split_addr_with_ipv4(self):
+        addr, port = controller._split_addr('127.0.0.1:6653')
+        eq_('127.0.0.1', addr)
+        eq_(6653, port)
+
+    def test_split_addr_with_ipv6(self):
+        addr, port = controller._split_addr('[::1]:6653')
+        eq_('::1', addr)
+        eq_(6653, port)
+
+    @raises(ValueError)
+    def test_split_addr_with_invalid_addr(self):
+        controller._split_addr('127.0.0.1')
+
+    @raises(ValueError)
+    def test_split_addr_with_invalid_ipv4_addr(self):
+        controller._split_addr('xxx.xxx.xxx.xxx:6653')
+
+    @raises(ValueError)
+    def test_split_addr_with_invalid_ipv6_addr(self):
+        controller._split_addr('[::xxxx]:6653')
+
+    @raises(ValueError)
+    def test_split_addr_with_non_bracketed_ipv6_addr(self):
+        controller._split_addr('::1:6653')
+
+
 class Test_Datapath(unittest.TestCase):
     """
     Test cases for controller.Datapath
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to