[Git][NTPsec/ntpsec][master] Moved slicedata() test to test_util.py, expanded test for edge cases

Ian Bruene gitlab at mg.gitlab.com
Wed Aug 23 21:03:57 UTC 2017


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
606335fa by Ian Bruene at 2017-08-23T16:02:43-05:00
Moved slicedata() test to test_util.py, expanded test for edge cases

- - - - -


2 changed files:

- tests/pylib/test_agentx.py
- tests/pylib/test_util.py


Changes:

=====================================
tests/pylib/test_agentx.py
=====================================
--- a/tests/pylib/test_agentx.py
+++ b/tests/pylib/test_agentx.py
@@ -2084,12 +2084,6 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         # Test little endian
         self.assertEqual(f(False), "<")
 
-    def test_slicedata(self):
-        f = ntp.agentx.slicedata
-
-        # Test
-        self.assertEqual(f("foobaz", 2), ("fo", "obaz"))
-
     def test_encode_pduheader(self):
         f = ntp.agentx.encode_pduheader
         a = ntp.agentx


=====================================
tests/pylib/test_util.py
=====================================
--- a/tests/pylib/test_util.py
+++ b/tests/pylib/test_util.py
@@ -44,6 +44,16 @@ class TestPylibUtilMethods(unittest.TestCase):
         self.assertEqual(ntp.util.rfc3339(1480999786.025),
                          '2016-12-06T04:49:46.03Z')
 
+    def test_slicedata(self):
+        f = ntp.util.slicedata
+
+        # Test normal
+        self.assertEqual(f("foobaz", 2), ("fo", "obaz"))
+        # Test overflow
+        self.assertEqual(f("foobaz", 8), ("foobaz", ""))
+        # Test underflow
+        self.assertEqual(f("foobaz", -2), ("foob", "az"))
+
     def test_portsplit(self):
         self.assertEqual(ntp.util.portsplit("host.invalid"),
                          ("host.invalid", ""))



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/606335fa0810c3a079e0f9f3bc95ca49e3f1b3d0

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/606335fa0810c3a079e0f9f3bc95ca49e3f1b3d0
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170823/fff234f9/attachment.html>


More information about the vc mailing list