| @@ -57,6 +57,9 @@ shakat: $(SHAKAT) | |||||
| shavs: shakat shamont | shavs: shakat shamont | ||||
| @echo "All known-answer tests passed" | @echo "All known-answer tests passed" | ||||
| test-python: | |||||
| python -m unittest Strobe.Test.copy | |||||
| test: shavs | test: shavs | ||||
| clean: | clean: | ||||
| @@ -42,6 +42,7 @@ class Strobe(object): | |||||
| (copy_of.R,copy_of.pos,copy_of.posbegin,copy_of.I0, | (copy_of.R,copy_of.pos,copy_of.posbegin,copy_of.I0, | ||||
| copy_of.F.copy()) | copy_of.F.copy()) | ||||
| self.st = bytearray(copy_of.st) | self.st = bytearray(copy_of.st) | ||||
| self.initialized = True | |||||
| def copy(self): return Strobe(None,copy_of=self) | def copy(self): return Strobe(None,copy_of=self) | ||||
| def deepcopy(self): return self.copy() | def deepcopy(self): return self.copy() | ||||
| @@ -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)) | |||||