def testLangCodesToMask(self):
        langInstance = Languages()

        codes = ["eng", "nld", "ita"]
        # eng is 0x40
        # nld is 0x80000
        # ita is 0x2000
        mask = langInstance.langCodesToMask(codes)
        self.assertEquals((0x40 | 0x80000 | 0x2000), mask)
Exemplo n.º 2
0
    def testLangCodesToMask(self):
        langInstance = Languages()

        codes = ["eng", "nld", "ita"]
        # eng is 0x40
        # nld is 0x80000
        # ita is 0x2000
        mask = langInstance.langCodesToMask(codes)
        self.assertEquals((0x40 | 0x80000 | 0x2000), mask)
    def testMaskToLangCodes(self):
        langInstance = Languages()

        eng, nld, ita = 0x40, 0x80000, 0x2000
        mask = eng | nld | ita

        codes = langInstance.maskToLangCodes(mask)

        self.assertEquals(set(codes), set(["eng", "nld", "ita"]))

        remask = 0
        for code in codes:
            remask = remask | langInstance.langMappings[code]

        self.assertEquals(mask, remask)
Exemplo n.º 4
0
    def testMaskToLangCodes(self):
        langInstance = Languages()

        eng, nld, ita = 0x40, 0x80000, 0x2000
        mask = eng | nld | ita

        codes = langInstance.maskToLangCodes(mask)

        self.assertEquals(set(codes), set(["eng","nld","ita"]))

        remask = 0
        for code in codes:
            remask = remask | langInstance.langMappings[code]

        self.assertEquals(mask, remask)
    def testInvalidLangCodesToMask(self):
        langInstance = Languages()

        #gne is an invalid language code
        codes = ["eng", "nld", "gne"]

        self.assertRaises(ValueError, langInstance.langCodesToMask, codes)
 def testLanguageInstance(self):
     langInstance = Languages()
     self.assertTrue(len(langInstance.supportedLanguages) == 32)
     self.assertTrue(len(langInstance.langMappings) == 32)
     #check if the mappings are all distinct values
     bitmasksSet = set(langInstance.langMappings.values())
     self.assertTrue(len(bitmasksSet) == 32)
    def testCorrectMapping(self):
        langInstance = Languages()
        #checking if they are distinct is not sufficient since  they
        #can be assigned wrong values
        fullMask = 0
        for mask in langInstance.langMappings.values():
            fullMask = fullMask ^ mask

        #since I know there are 32 different language masks
        self.assertEqual(0xFFFFFFFF, fullMask)
    def testMaskToLangCodesLongerMask(self):
        langInstance = Languages()
        mask = 0x1FFFFFFFF  #36 bits!

        self.assertRaises(AssertionError, langInstance.maskToLangCodes,
                          (mask, ))
 def testLangCodesToMaskEmpty(self):
     langInstance = Languages()
     codes = []
     mask = langInstance.langCodesToMask(codes)
     self.assertEquals(0, mask)
Exemplo n.º 10
0
 def testLangCodesToMaskEmpty(self):
     langInstance = Languages()
     codes = []
     mask = langInstance.langCodesToMask(codes)
     self.assertEquals(0,mask)