Пример #1
0
    def test_range(self):
        ''' Get range. '''
        fr = FmapRange((-11, -4, 3, 0), (3, 5, 7, 11))

        self.assertEqual(len(set(fr.range('n', 'w'))), fr.size('n', 'w'),
                         'range: nw: len')
        self.assertEqual(len(set(fr.range('h'))), fr.size('h'), 'range: h: len')
        self.assertEqual(len(set(fr.range())), fr.size(), 'range: all: len')

        be_b, be_w = fr.beg_end('b', 'w')
        for pnt in fr.range('b', 'w'):
            self.assertGreaterEqual(pnt[0], be_b[0], 'range: b: >=')
            self.assertLess(pnt[0], be_b[1], 'range: b: <')
            self.assertGreaterEqual(pnt[1], be_w[0], 'range: w: >=')
            self.assertLess(pnt[1], be_w[1], 'range: w: <')

        for fp in fr.range():
            self.assertTrue(fp in fr, 'range: all: in')
Пример #2
0
    def test_contains(self):
        ''' Whether contains fmap point. '''
        fr = FmapRange((-11, -4, 3, 0), (3, 5, 7, 11))

        for fp in fr.range():
            self.assertTrue(fp in fr, 'contains')

        num = 0
        for fp in FmapRange((-12, -12, -12, -12), (12, 12, 12, 12)).range():
            num += 1 if fp in fr else 0
        self.assertEqual(num, fr.size())