Example #1
0
 def test_complement(self):
     cds = UnicodeSubset([50, 90, 10, 90])
     self.assertEqual(list(cds.complement()), [(0, 10), (11, 50), (51, 90), (91, sys.maxunicode + 1)])
     cds.add(11)
     self.assertEqual(list(cds.complement()), [(0, 10), (12, 50), (51, 90), (91, sys.maxunicode + 1)])
     cds.add((0, 10))
     self.assertEqual(list(cds.complement()), [(12, 50), (51, 90), (91, sys.maxunicode + 1)])
Example #2
0
    def test_complement(self):
        cds = UnicodeSubset([50, 90, 10, 90])
        self.assertEqual(list(cds.complement()), [(0, 10), (11, 50), (51, 90), (91, sys.maxunicode + 1)])
        cds.add(11)
        self.assertEqual(list(cds.complement()), [(0, 10), (12, 50), (51, 90), (91, sys.maxunicode + 1)])
        cds.add((0, 10))
        self.assertEqual(list(cds.complement()), [(12, 50), (51, 90), (91, sys.maxunicode + 1)])

        cds1 = UnicodeSubset(chain(
            UNICODE_CATEGORIES['L'].code_points,
            UNICODE_CATEGORIES['M'].code_points,
            UNICODE_CATEGORIES['N'].code_points,
            UNICODE_CATEGORIES['S'].code_points
        ))
        cds2 = UnicodeSubset(chain(
            UNICODE_CATEGORIES['C'].code_points,
            UNICODE_CATEGORIES['P'].code_points,
            UNICODE_CATEGORIES['Z'].code_points
        ))
        self.assertListEqual(cds1.code_points, UnicodeSubset(cds2.complement()).code_points)