class ManchesterDecodeTests(unittest.TestCase):
    def setUp(self):
        self.codec = Manchester()

    def test_decode(self):
        self.assertEqual(self.codec.decode(symbols), bits)

    def test_invert_decode(self):
        self.codec.invert()
        self.assertEqual(self.codec.decode(symbols), invert_bits)
class ManchesterEncodeTests(unittest.TestCase):
    def setUp(self):
        self.codec = Manchester()

    def test_encode(self):
        self.assertEqual(self.codec.encode(bits), symbols)

    def test_invert_encode(self):
        self.codec.invert()
        self.assertEqual(self.codec.encode(bits), invert_symbols)
class DifferentialManchesterDecodeTests(unittest.TestCase):
    def setUp(self):
        self.codec = Manchester(differential=True)

    def test_decode(self):
        for symbols in diff_symbols:
            self.assertEqual(self.codec.decode(symbols), bits)

    def test_invert_decode(self):
        for invert_symbols in invert_diff_symbols:
            self.assertEqual(self.codec.decode(invert_symbols), invert_bits)
class DifferentialManchesterEncodeTests(unittest.TestCase):
    def setUp(self):
        self.codec = Manchester(differential=True)

    def test_encode(self):
        self.assertIn(self.codec.encode(bits), diff_symbols)
        for symbols in diff_symbols:
            init_level = symbols[0] == '1' and '0' or '1'
            self.assertEqual(self.codec.encode(bits, init_level=init_level),
                             symbols)

    def test_invert_encode(self):
        self.assertIn(self.codec.encode(invert_bits), invert_diff_symbols)
        for symbols in invert_diff_symbols:
            init_level = symbols[0] == '1' and '0' or '1'
            self.assertEqual(
                self.codec.encode(invert_bits, init_level=init_level), symbols)
 def setUp(self):
     self.codec = Manchester(differential=True)
 def setUp(self):
     self.codec = Manchester()
from nrzi import NRZI
from hdb3 import HDB3
from manchester import Manchester
from multilevel import Multilevel

bits = Manchester("10110010")
bits.encode()
print("Bits:", bits.get_bits())
print("Code:", bits.get_code())

bits.plot()