def testcoalesce(self):
        # check that mixed-type coalescing works
        x = segments.segmentlist(
            [segments.segment(1, 2),
             segments.segment(3, 4), (2, 3)])
        try:
            self.assertEqual(x.coalesce(),
                             segments.segmentlist([segments.segment(1, 4)]))
        except AssertionError as e:
            raise AssertionError("mixed type coalesce failed:  got %s" %
                                 str(x))

        # try a bunch of random segment lists
        for i in range(algebra_repeats):
            a = verifyutils.random_uncoalesced_list(
                random.randint(1, algebra_listlength))
            b = segments.segmentlist(a[:]).coalesce()
            try:
                self.assertTrue(verifyutils.iscoalesced(b))
                for seg in a:
                    self.assertTrue(seg in b)
                for seg in a:
                    b -= segments.segmentlist([seg])
                self.assertEqual(b, segments.segmentlist([]))
            except AssertionError as e:
                raise AssertionError(
                    str(e) + "\na = " + str(a) + "\nb = " + str(b))
	def test__or__(self):
		for i in range(algebra_repeats):
			a = verifyutils.random_coalesced_list(random.randint(1, algebra_listlength))
			b = verifyutils.random_coalesced_list(random.randint(1, algebra_listlength))
			c = a | b
			try:
				# make sure c is coalesced
				self.assertTrue(verifyutils.iscoalesced(c))
				# make sure c contains all of a
				self.assertEqual(a, c & a)
				# make sure c contains all of b
				self.assertEqual(b, c & b)
				# make sure c contains nothing except a and b
				self.assertEqual(segments.segmentlist([]), c - a - b)
			except AssertionError as e:
				raise AssertionError(str(e) + "\na = " + str(a) + "\nb = " + str(b))
Exemple #3
0
    def test_or(self):
        for i in range(algebra_repeats):
            a = verifyutils.random_coalesced_list(
                random.randint(1, algebra_listlength))
            b = verifyutils.random_coalesced_list(
                random.randint(1, algebra_listlength))
            c = a | b

            # make sure c is coalesced
            assert verifyutils.iscoalesced(c)
            # make sure c contains all of a
            assert a == c & a
            # make sure c contains all of b
            assert b == c & b
            # make sure c contains nothing except a and b
            assert segments.segmentlist([]) == c - a - b
Exemple #4
0
 def test__or__(self):
     for i in xrange(algebra_repeats):
         a = verifyutils.random_coalesced_list(
             random.randint(1, algebra_listlength))
         b = verifyutils.random_coalesced_list(
             random.randint(1, algebra_listlength))
         c = a | b
         try:
             # make sure c is coalesced
             self.assertTrue(verifyutils.iscoalesced(c))
             # make sure c contains all of a
             self.assertEqual(a, c & a)
             # make sure c contains all of b
             self.assertEqual(b, c & b)
             # make sure c contains nothing except a and b
             self.assertEqual(segments.segmentlist([]), c - a - b)
         except AssertionError, e:
             raise AssertionError, str(e) + "\na = " + str(
                 a) + "\nb = " + str(b)
	def testcoalesce(self):
		# check that mixed-type coalescing works
		x = segments.segmentlist([segments.segment(1, 2), segments.segment(3, 4), (2, 3)])
		try:
			self.assertEqual(x.coalesce(), segments.segmentlist([segments.segment(1, 4)]))
		except AssertionError as e:
			raise AssertionError("mixed type coalesce failed:  got %s" % str(x))

		# try a bunch of random segment lists
		for i in range(algebra_repeats):
			a = verifyutils.random_uncoalesced_list(random.randint(1, algebra_listlength))
			b = segments.segmentlist(a[:]).coalesce()
			try:
				self.assertTrue(verifyutils.iscoalesced(b))
				for seg in a:
					self.assertTrue(seg in b)
				for seg in a:
					b -= segments.segmentlist([seg])
				self.assertEqual(b, segments.segmentlist([]))
			except AssertionError as e:
				raise AssertionError(str(e) + "\na = " + str(a) + "\nb = " + str(b))
Exemple #6
0
    def test_coalesce(self):
        # check that mixed-type coalescing works
        x = segments.segmentlist(
            [segments.segment(1, 2),
             segments.segment(3, 4), (2, 3)])
        try:
            assert x.coalesce() == segments.segmentlist(
                [segments.segment(1, 4)])
        except AssertionError as e:
            raise AssertionError("mixed type coalesce failed:  got %s" %
                                 str(x))

        # try a bunch of random segment lists
        for i in range(algebra_repeats):
            a = verifyutils.random_uncoalesced_list(
                random.randint(1, algebra_listlength))
            b = segments.segmentlist(a[:]).coalesce()
            assert verifyutils.iscoalesced(b)
            for seg in a:
                assert seg in b
            for seg in a:
                b -= segments.segmentlist([seg])
            assert b == segments.segmentlist([])
		self.assertEqual(segments.segmentlist([(1, 0)]).extent(), segments.segment(0, 1))

	def testcoalesce(self):
		# check that mixed-type coalescing works
		x = segments.segmentlist([segments.segment(1, 2), segments.segment(3, 4), (2, 3)])
		try:
			self.assertEqual(x.coalesce(), segments.segmentlist([segments.segment(1, 4)]))
		except AssertionError, e:
			raise AssertionError, "mixed type coalesce failed:  got %s" % str(x)

		# try a bunch of random segment lists
		for i in xrange(algebra_repeats):
			a = verifyutils.random_uncoalesced_list(random.randint(1, algebra_listlength))
			b = segments.segmentlist(a[:]).coalesce()
			try:
				self.assertTrue(verifyutils.iscoalesced(b))
				for seg in a:
					self.assertTrue(seg in b)
				for seg in a:
					b -= segments.segmentlist([seg])
				self.assertEqual(b, segments.segmentlist([]))
			except AssertionError, e:
				raise AssertionError, str(e) + "\na = " + str(a) + "\nb = " + str(b)

	def test_typesafety(self):
		w = "segments.segmentlist([segments.segment(0, 10), segments.segment(20, 30)])"
		x = "segments.segment(10, 20)"
		y = "[(10, 20)]"
		z = "None"

		for op in ("|", "&", "-", "^"):
Exemple #8
0
            [segments.segment(1, 2),
             segments.segment(3, 4), (2, 3)])
        try:
            self.assertEqual(x.coalesce(),
                             segments.segmentlist([segments.segment(1, 4)]))
        except AssertionError, e:
            raise AssertionError, "mixed type coalesce failed:  got %s" % str(
                x)

        # try a bunch of random segment lists
        for i in xrange(algebra_repeats):
            a = verifyutils.random_uncoalesced_list(
                random.randint(1, algebra_listlength))
            b = segments.segmentlist(a[:]).coalesce()
            try:
                self.assertTrue(verifyutils.iscoalesced(b))
                for seg in a:
                    self.assertTrue(seg in b)
                for seg in a:
                    b -= segments.segmentlist([seg])
                self.assertEqual(b, segments.segmentlist([]))
            except AssertionError, e:
                raise AssertionError, str(e) + "\na = " + str(
                    a) + "\nb = " + str(b)

    def test_typesafety(self):
        w = "segments.segmentlist([segments.segment(0, 10), segments.segment(20, 30)])"
        x = "segments.segment(10, 20)"
        y = "[(10, 20)]"
        z = "None"