MCPcopy Index your code
hub / github.com/python/cpython / test_hamt_delete_5

Method test_hamt_delete_5

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

Source from the content-addressed store, hash-verified

1062 self.assertEqual(len(h), 0)
1063
1064 def test_hamt_delete_5(self):
1065 h = hamt()
1066
1067 keys = []
1068 for i in range(17):
1069 key = HashKey(i, str(i))
1070 keys.append(key)
1071 h = h.set(key, f'val-{i}')
1072
1073 collision_key16 = HashKey(16, '18')
1074 h = h.set(collision_key16, 'collision')
1075
1076 # ArrayNode(id=0x10f8b9318):
1077 # 0::
1078 # BitmapNode(size=2 count=1 bitmap=0b1):
1079 # <Key name:0 hash:0>: 'val-0'
1080 #
1081 # ... 14 more BitmapNodes ...
1082 #
1083 # 15::
1084 # BitmapNode(size=2 count=1 bitmap=0b1):
1085 # <Key name:15 hash:15>: 'val-15'
1086 #
1087 # 16::
1088 # BitmapNode(size=2 count=1 bitmap=0b1):
1089 # NULL:
1090 # CollisionNode(size=4 id=0x10f2f5af8):
1091 # <Key name:16 hash:16>: 'val-16'
1092 # <Key name:18 hash:16>: 'collision'
1093
1094 self.assertEqual(len(h), 18)
1095
1096 h = h.delete(keys[2])
1097 self.assertEqual(len(h), 17)
1098
1099 h = h.delete(collision_key16)
1100 self.assertEqual(len(h), 16)
1101 h = h.delete(keys[16])
1102 self.assertEqual(len(h), 15)
1103
1104 h = h.delete(keys[1])
1105 self.assertEqual(len(h), 14)
1106 h = h.delete(keys[1])
1107 self.assertEqual(len(h), 14)
1108
1109 for key in keys:
1110 h = h.delete(key)
1111 self.assertEqual(len(h), 0)
1112
1113 def test_hamt_items_1(self):
1114 A = HashKey(100, 'A')

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected