Browse Source

add tests for copy, and fix up copy method to work properly

mbed-sx1276
John-Mark Gurney 3 years ago
parent
commit
552d42c622
3 changed files with 25 additions and 0 deletions
  1. +3
    -0
      strobe/python/Makefile
  2. +1
    -0
      strobe/python/Strobe/Strobe.py
  3. +21
    -0
      strobe/python/Strobe/Test/copy.py

+ 3
- 0
strobe/python/Makefile View File

@@ -57,6 +57,9 @@ shakat: $(SHAKAT)
shavs: shakat shamont
@echo "All known-answer tests passed"

test-python:
python -m unittest Strobe.Test.copy

test: shavs

clean:


+ 1
- 0
strobe/python/Strobe/Strobe.py View File

@@ -42,6 +42,7 @@ class Strobe(object):
(copy_of.R,copy_of.pos,copy_of.posbegin,copy_of.I0,
copy_of.F.copy())
self.st = bytearray(copy_of.st)
self.initialized = True
def copy(self): return Strobe(None,copy_of=self)
def deepcopy(self): return self.copy()


+ 21
- 0
strobe/python/Strobe/Test/copy.py View File

@@ -0,0 +1,21 @@
# Test to make sure copy works.

import unittest

from Strobe.Strobe import Strobe

class TestCopy(unittest.TestCase):
def test_copy(self):
a = Strobe(b'foo')
b = Strobe(b'foo')

msg = a.send_enc(b'atest')
self.assertEqual(b'atest', b.recv_enc(msg))

c = b.copy()

msg = a.send_enc(b'anothertest')

# that both the original and copy work
self.assertEqual(b'anothertest', b.recv_enc(msg))
self.assertEqual(b'anothertest', c.recv_enc(msg))

Loading…
Cancel
Save