MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_hamt_delete_5

Method test_hamt_delete_5

Lib/test/test_context.py:851–898  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

849 self.assertEqual(len(h), 0)
850
851 def test_hamt_delete_5(self):
852 h = hamt()
853
854 keys = []
855 for i in range(17):
856 key = HashKey(i, str(i))
857 keys.append(key)
858 h = h.set(key, f'val-{i}')
859
860 collision_key16 = HashKey(16, '18')
861 h = h.set(collision_key16, 'collision')
862
863 # ArrayNode(id=0x10f8b9318):
864 # 0::
865 # BitmapNode(size=2 count=1 bitmap=0b1):
866 # <Key name:0 hash:0>: 'val-0'
867 #
868 # ... 14 more BitmapNodes ...
869 #
870 # 15::
871 # BitmapNode(size=2 count=1 bitmap=0b1):
872 # <Key name:15 hash:15>: 'val-15'
873 #
874 # 16::
875 # BitmapNode(size=2 count=1 bitmap=0b1):
876 # NULL:
877 # CollisionNode(size=4 id=0x10f2f5af8):
878 # <Key name:16 hash:16>: 'val-16'
879 # <Key name:18 hash:16>: 'collision'
880
881 self.assertEqual(len(h), 18)
882
883 h = h.delete(keys[2])
884 self.assertEqual(len(h), 17)
885
886 h = h.delete(collision_key16)
887 self.assertEqual(len(h), 16)
888 h = h.delete(keys[16])
889 self.assertEqual(len(h), 15)
890
891 h = h.delete(keys[1])
892 self.assertEqual(len(h), 14)
893 h = h.delete(keys[1])
894 self.assertEqual(len(h), 14)
895
896 for key in keys:
897 h = h.delete(key)
898 self.assertEqual(len(h), 0)
899
900 def test_hamt_items_1(self):
901 A = HashKey(100, 'A')

Callers

nothing calls this directly

Calls 7

HashKeyClass · 0.85
strFunction · 0.85
lenFunction · 0.85
appendMethod · 0.45
setMethod · 0.45
assertEqualMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected