def test_beg_end(self): ''' Get beg_end. ''' fr = FmapRange((-11, -4, 3, 0), (3, 5, 7, 11)) be = fr.beg_end('n') self.assertTupleEqual(be, (-4, 5), 'beg_end: n: val') be = fr.beg_end('h') self.assertTupleEqual(be, (3, 7), 'beg_end: h: val') be_b, be_w = fr.beg_end('b', 'w') self.assertTupleEqual(be_b, (-11, 3), 'beg_end: b: val') self.assertTupleEqual(be_w, (0, 11), 'beg_end: w: val') be_all = fr.beg_end() self.assertEqual(len(be_all), 4, 'beg_end: all: len') self.assertTupleEqual(be_all[0], (-11, 3), 'beg_end: all: b: val') self.assertTupleEqual(be_all[1], (-4, 5), 'beg_end: all: n: val') self.assertTupleEqual(be_all[2], (3, 7), 'beg_end: all: h: val') self.assertTupleEqual(be_all[3], (0, 11), 'beg_end: all: w: val')
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')