Lines Matching +full:key +full:- +full:2

1 // SPDX-License-Identifier: GPL-2.0
13 int key; member
22 DEFINE_HASHTABLE(hash1, 2); in hashtable_test_hash_init()
41 a.key = 1; in hashtable_test_hash_empty()
43 hash_add(hash, &a.node, a.key); in hashtable_test_hash_empty()
54 a.key = 1; in hashtable_test_hash_hashed()
56 hash_add(hash, &a.node, a.key); in hashtable_test_hash_hashed()
57 b.key = 1; in hashtable_test_hash_hashed()
58 b.data = 2; in hashtable_test_hash_hashed()
59 hash_add(hash, &b.node, b.key); in hashtable_test_hash_hashed()
71 a.key = 1; in hashtable_test_hash_add()
74 hash_add(hash, &a.node, a.key); in hashtable_test_hash_add()
75 b.key = 2; in hashtable_test_hash_add()
78 hash_add(hash, &b.node, b.key); in hashtable_test_hash_add()
81 x->visited++; in hashtable_test_hash_add()
82 if (x->key == a.key) in hashtable_test_hash_add()
83 KUNIT_EXPECT_EQ(test, x->data, 13); in hashtable_test_hash_add()
84 else if (x->key == b.key) in hashtable_test_hash_add()
85 KUNIT_EXPECT_EQ(test, x->data, 10); in hashtable_test_hash_add()
87 KUNIT_FAIL(test, "Unexpected key in hashtable."); in hashtable_test_hash_add()
100 a.key = 1; in hashtable_test_hash_del()
102 hash_add(hash, &a.node, a.key); in hashtable_test_hash_del()
103 b.key = 2; in hashtable_test_hash_del()
106 hash_add(hash, &b.node, b.key); in hashtable_test_hash_del()
109 hash_for_each_possible(hash, x, node, b.key) { in hashtable_test_hash_del()
110 x->visited++; in hashtable_test_hash_del()
111 KUNIT_EXPECT_NE(test, x->key, b.key); in hashtable_test_hash_del()
132 entries[i].key = i; in hashtable_test_hash_for_each()
135 hash_add(hash, &entries[i].node, entries[i].key); in hashtable_test_hash_for_each()
140 x->visited += 1; in hashtable_test_hash_for_each()
141 KUNIT_ASSERT_GE_MSG(test, x->key, 0, "Unexpected key in hashtable."); in hashtable_test_hash_for_each()
142 KUNIT_ASSERT_LT_MSG(test, x->key, 3, "Unexpected key in hashtable."); in hashtable_test_hash_for_each()
162 entries[i].key = i; in hashtable_test_hash_for_each_safe()
165 hash_add(hash, &entries[i].node, entries[i].key); in hashtable_test_hash_for_each_safe()
170 x->visited += 1; in hashtable_test_hash_for_each_safe()
171 KUNIT_ASSERT_GE_MSG(test, x->key, 0, "Unexpected key in hashtable."); in hashtable_test_hash_for_each_safe()
172 KUNIT_ASSERT_LT_MSG(test, x->key, 3, "Unexpected key in hashtable."); in hashtable_test_hash_for_each_safe()
176 hash_del(&x->node); in hashtable_test_hash_for_each_safe()
189 int buckets[2]; in hashtable_test_hash_for_each_possible()
193 /* Add three entries with key = 0 to the hashtable. */ in hashtable_test_hash_for_each_possible()
195 entries[i].key = 0; in hashtable_test_hash_for_each_possible()
198 hash_add(hash, &entries[i].node, entries[i].key); in hashtable_test_hash_for_each_possible()
201 /* Add an entry with key = 1. */ in hashtable_test_hash_for_each_possible()
202 entries[3].key = 1; in hashtable_test_hash_for_each_possible()
205 hash_add(hash, &entries[3].node, entries[3].key); in hashtable_test_hash_for_each_possible()
209 x->visited += 1; in hashtable_test_hash_for_each_possible()
210 KUNIT_ASSERT_GE_MSG(test, x->data, 0, "Unexpected data in hashtable."); in hashtable_test_hash_for_each_possible()
211 KUNIT_ASSERT_LT_MSG(test, x->data, 4, "Unexpected data in hashtable."); in hashtable_test_hash_for_each_possible()
215 /* Should have visited each entry with key = 0 exactly once. */ in hashtable_test_hash_for_each_possible()
221 KUNIT_ASSERT_GE_MSG(test, y->key, 0, "Unexpected key in hashtable."); in hashtable_test_hash_for_each_possible()
222 KUNIT_ASSERT_LE_MSG(test, y->key, 1, "Unexpected key in hashtable."); in hashtable_test_hash_for_each_possible()
223 buckets[y->key] = bkt; in hashtable_test_hash_for_each_possible()
226 /* If entry with key = 1 is in the same bucket as the entries with in hashtable_test_hash_for_each_possible()
227 * key = 0, check it was visited. Otherwise ensure that only three in hashtable_test_hash_for_each_possible()
244 int buckets[2]; in hashtable_test_hash_for_each_possible_safe()
248 /* Add three entries with key = 0 to the hashtable. */ in hashtable_test_hash_for_each_possible_safe()
250 entries[i].key = 0; in hashtable_test_hash_for_each_possible_safe()
253 hash_add(hash, &entries[i].node, entries[i].key); in hashtable_test_hash_for_each_possible_safe()
256 /* Add an entry with key = 1. */ in hashtable_test_hash_for_each_possible_safe()
257 entries[3].key = 1; in hashtable_test_hash_for_each_possible_safe()
260 hash_add(hash, &entries[3].node, entries[3].key); in hashtable_test_hash_for_each_possible_safe()
264 x->visited += 1; in hashtable_test_hash_for_each_possible_safe()
265 KUNIT_ASSERT_GE_MSG(test, x->data, 0, "Unexpected data in hashtable."); in hashtable_test_hash_for_each_possible_safe()
266 KUNIT_ASSERT_LT_MSG(test, x->data, 4, "Unexpected data in hashtable."); in hashtable_test_hash_for_each_possible_safe()
270 hash_del(&x->node); in hashtable_test_hash_for_each_possible_safe()
273 /* Should have visited each entry with key = 0 exactly once. */ in hashtable_test_hash_for_each_possible_safe()
279 KUNIT_ASSERT_GE_MSG(test, y->key, 0, "Unexpected key in hashtable."); in hashtable_test_hash_for_each_possible_safe()
280 KUNIT_ASSERT_LE_MSG(test, y->key, 1, "Unexpected key in hashtable."); in hashtable_test_hash_for_each_possible_safe()
281 buckets[y->key] = bkt; in hashtable_test_hash_for_each_possible_safe()
284 /* If entry with key = 1 is in the same bucket as the entries with in hashtable_test_hash_for_each_possible_safe()
285 * key = 0, check it was visited. Otherwise ensure that only three in hashtable_test_hash_for_each_possible_safe()