예제 #1
0
            def run(self):
                asninteger = asn_ints.AsnInt(self.nm)
                asnbuf = asn_buffer.AsnBuf()

                self.assertTrue(asninteger.BEnc(asnbuf) == self.ln)
                byteCodes = asnbuf.Buffer()
                self.assertTrue(len(byteCodes) == len(self.bc))
                for x in range(len(byteCodes)):
                    self.assertTrue(self.bc[x] == byteCodes[x])
                return True
예제 #2
0
    def test_operations_default(self):
        asninteger = asn_ints.AsnInt(1)

        self.assertTrue(asninteger == 1)
        self.assertTrue(asninteger > 0)
        self.assertTrue(asninteger < 2)

        asninteger += 1

        self.assertTrue(asninteger == 2)
        self.assertTrue((asninteger * 1) == 2)
        self.assertTrue((asninteger - 1) == 1)
예제 #3
0
            def run(self):
                cnstraint_good = asn_ints.IntegerConstraint(self.nm-1, self.nm+1)
                asninteger = asn_ints.AsnInt(self.nm)
                asninteger.addConstraint(cnstraint_good)

                buf = asn_buffer.AsnBuf()
                self.assertTrue(asninteger.BEnc(buf) != 0)

                cnstraint_bad = asn_ints.IntegerConstraint(self.nm+1, self.nm+2)
                asninteger.addConstraint(cnstraint_bad)
                with self.assertRaises(ValueError):
                    asninteger.BEnc(buf)
                return True
예제 #4
0
 def run(self):
     asnbuf = asn_buffer.AsnBuf(self.bc)
     asninteger = asn_ints.AsnInt()
     self.assertTrue(asninteger.BDec(asnbuf, 0) == self.ln)
     self.assertTrue(self.nm == int(asninteger))
     return True