Ejemplo n.º 1
0
    def test_stability(self):
        for number in xrange(50):
            largeN = 91 ** number
            text = base91.from_decimal(largeN)
            result = base91.to_decimal(text)

            self.assertEqual(result, largeN)
    def telemString(self, telem):
        text = ["|"]

        # sequence
        if "seq" in telem:
            text.append(base91.from_decimal(telem["seq"], 2))

        # telemetry channels
        if "vals" in telem:
            for val in telem["vals"]:
                text.append(base91.from_decimal(val, 2))

        # bits as str(11111111)
        if "bits" in telem:
            val = int(telem["bits"][::-1], 2)
            text.append(base91.from_decimal(val, 2))

        text.append("|")

        return "".join(text)
    def telemString(self, telem):
        text = ['|']

        # sequence
        if 'seq' in telem:
            text.append(base91.from_decimal(telem['seq'], 2))

        # telemetry channels
        if 'vals' in telem:
            for val in telem['vals']:
                text.append(base91.from_decimal(val, 2))

        # bits as str(11111111)
        if 'bits' in telem:
            val = int(telem['bits'][::-1], 2)
            text.append(base91.from_decimal(val, 2))

        text.append("|")

        return "".join(text)
Ejemplo n.º 4
0
    def test_valid_input(self):
        testData = [[0, "!"], [1, '"'], [90, "{"], [91, '"!']]

        # 91**1 = "!
        # 91**2 = "!!
        # 91**3 = "!!!
        # etc
        testData += [[91 ** i, '"' + "!" * i] for i in range(20)]

        for n, expected in testData:
            self.assertEqual(expected, base91.from_decimal(n))
Ejemplo n.º 5
0
    def test_from_decimal_to_decimal(self):
        for number in xrange(91**2 + 5):
            text = base91.from_decimal(number)
            result = base91.to_decimal(text)

            self.assertEqual(result, number)
Ejemplo n.º 6
0
    def test_valid_padding(self):
        testData = [1, 2, 5, 10, 100]

        for n in testData:
            self.assertEqual(n, len(base91.from_decimal(0, n)))
Ejemplo n.º 7
0
 def test_negative_width(self):
     for n in [0, -1, -100]:
         self.assertEqual(base91.from_decimal(0, width=n), '!')
Ejemplo n.º 8
0
    def test_valid_width(self):
        testData = [1, 2, 5, 10, 100]

        for n in testData:
            self.assertEqual(n, len(base91.from_decimal(0, n)))
Ejemplo n.º 9
0
    def test_from_decimal_to_decimal(self):
        for number in range(91**2 + 5):
            text = base91.from_decimal(number)
            result = base91.to_decimal(text)

            self.assertEqual(result, number)
Ejemplo n.º 10
0
 def test_negative_width(self):
     for n in [0, -1, -100]:
         self.assertEqual(base91.from_decimal(0, width=n), '!')