⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testpermutations.py

📁 java bitvector implementation.
💻 PY
字号:
import BitVectorimport unittestbv1 = BitVector.BitVector( bitlist = [1,0,0,1,1,0,1] )bv2 = BitVector.BitVector( bitlist = [1,0,1,0,0,1,1] )permutationTests = [    ((bv1, 'permute', '6201543'), '1010011'),    ((bv2, 'unpermute', '6201543'), '1001101'),    ]class PermutationTestCase(unittest.TestCase):    def checkPermutations(self):        print "\nTesting permutations"         for args, expected in permutationTests:            try:                if (args[1] == 'permute'):                    actual = args[0].permute( map( lambda x: int(x),                                                   list( args[2] ) ) )                elif (args[1] == 'unpermute'):                    actual = args[0].unpermute( map( lambda x: int(x),                                                     list( args[2] ) ) )                assert actual == BitVector.BitVector( bitstring = expected )            except Exception, e:                print e                print "Permutation test failed"def getTestSuites(type):    return unittest.TestSuite([            unittest.makeSuite(PermutationTestCase, type)                ])                    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -