Exemplo n.º 1
0
 def test_from_iterable(self):
     def gen6842():
         yield 6
         yield 8
         yield 4
         yield 2
     g = gen6842()
     s = SortedSet(g)
Exemplo n.º 2
0
 def test_reversed(self):
     s = SortedSet([1, 3, 5, 7])
     r = reversed(s)
     self.assertEqual(next(r), 7)
     self.assertEqual(next(r), 5)
     self.assertEqual(next(r), 3)
     self.assertEqual(next(r), 1)
     with self.assertRaises(StopIteration):
         next(r)
Exemplo n.º 3
0
 def test_one(self):
     s = SortedSet([42])
     self.assertEqual(len(s), 1)
Exemplo n.º 4
0
 def test_isdisjoint_negative(self):
     s = SortedSet({1, 2, 3})
     t = [3, 4, 5]
     self.assertFalse(s.isdisjoint(t))
Exemplo n.º 5
0
 def setUp(self):
     self.s = SortedSet([6, 7, 3, 9])
Exemplo n.º 6
0
 def test_symmetric_difference(self):
     s = SortedSet({1, 2, 3})
     t = [2, 3, 4]
     self.assertEqual(s.symmetric_difference(t), SortedSet({1, 4}))
Exemplo n.º 7
0
 def test_intersection(self):
     s = SortedSet({1, 2, 3})
     t = [2, 3, 4]
     self.assertEqual(s.intersection(t), SortedSet({2, 3}))
Exemplo n.º 8
0
 def test_issuperset_positive(self):
     s = SortedSet({1, 2, 3})
     t = [1, 2, 3]
     self.assertTrue(s.issuperset(t))
Exemplo n.º 9
0
 def test_default_empty(self):
     s = SortedSet()
Exemplo n.º 10
0
 def test_type_mismatch(self):
     self.assertFalse(SortedSet([4, 5, 6]) == [4, 5, 6])
Exemplo n.º 11
0
 def test_negative_equal(self):
     self.assertFalse(SortedSet([4, 5, 6]) == SortedSet([1, 2, 3]))
Exemplo n.º 12
0
 def test_positive_equal(self):
     self.assertTrue(SortedSet([4, 5, 6]) == SortedSet([6, 5, 4]))
Exemplo n.º 13
0
 def test_count_one(self):
     s = SortedSet([1, 5, 7, 9])
     self.assertEqual(s.count(7), 1)
Exemplo n.º 14
0
 def test_count_zero(self):
     s = SortedSet([1, 5, 7, 9])
     self.assertEqual(s.count(11), 0)
Exemplo n.º 15
0
 def test_index_negative(self):
     s = SortedSet([1, 5, 8, 9])
     with self.assertRaises(ValueError):
         s.index(15)
Exemplo n.º 16
0
 def test_with_duplicates(self):
     s = SortedSet([5, 5, 5])
     self.assertEqual(len(s), 1)
Exemplo n.º 17
0
 def test_index_positive(self):
     s = SortedSet([1, 5, 8, 9])
     self.assertEqual(s.index(8), 2)
Exemplo n.º 18
0
 def test_identical(self):
     s = SortedSet([10, 11, 12])
     self.assertTrue(s == s)
Exemplo n.º 19
0
 def test_ge_positive(self):
     s = SortedSet({1, 2})
     t = SortedSet({1, 2, 3})
     self.assertFalse(s >= t)
Exemplo n.º 20
0
 def test_positive_unequal(self):
     self.assertTrue(SortedSet([4, 5, 6]) != SortedSet([1, 2, 3]))
Exemplo n.º 21
0
 def test_issubset_negative(self):
     s = SortedSet({1, 2})
     t = [1, 2, 3]
     self.assertFalse(s.issuperset(t))
Exemplo n.º 22
0
 def test_negative_unequal(self):
     self.assertFalse(SortedSet([4, 5, 6]) != SortedSet([6, 5, 4]))
Exemplo n.º 23
0
 def test_union(self):
     s = SortedSet({1, 2, 3})
     t = [2, 3, 4]
     self.assertEqual(s.union(t), SortedSet({1, 2, 3, 4}))
Exemplo n.º 24
0
 def test_type_mismatch(self):
     self.assertTrue(SortedSet([4, 5, 6]) != [4, 5, 6])
Exemplo n.º 25
0
 def test_difference(self):
     s = SortedSet({1, 2, 3})
     t = [2, 3, 4]
     self.assertEqual(s.difference(t), SortedSet({1}))
Exemplo n.º 26
0
 def test_identical(self):
     s = SortedSet([10, 11, 12])
     self.assertFalse(s != s)
Exemplo n.º 27
0
 def test_isdisjoint_positive(self):
     s = SortedSet({1, 2, 3})
     t = [4, 5, 6]
     self.assertTrue(s.isdisjoint(t))
Exemplo n.º 28
0
 def test_le_lt_positive(self):
     s = SortedSet({1, 2})
     t = SortedSet({1, 2, 3})
     self.assertTrue(s <= t)
Exemplo n.º 29
0
 def test_empty(self):
     s = SortedSet()
     self.assertEqual(len(s), 0)
Exemplo n.º 30
0
 def test_gt_positive(self):
     s = SortedSet({1, 2, 3})
     t = SortedSet({1, 2})
     self.assertTrue(s > t)
Exemplo n.º 31
0
 def test_ten(self):
     s = SortedSet(range(10))
     self.assertEqual(len(s), 10)
Exemplo n.º 32
0
 def test_gt_negative(self):
     s = SortedSet({1, 2})
     t = SortedSet({1, 2, 3})
     self.assertFalse(s > t)
Exemplo n.º 33
0
 def setUp(self):
     self.s = SortedSet([7, 2, 1, 1, 9])
Exemplo n.º 34
0
 def test_ge_eq_positive(self):
     s = SortedSet({1, 2, 3})
     t = SortedSet({1, 2, 3})
     self.assertTrue(s >= t)