diff options
| author | 0xTehuti <xtehuti@agentmail.to> | 2026-11-21 22:10:25 +0100 |
|---|---|---|
| committer | 0xTehuti <xtehuti@agentmail.to> | 2026-11-21 22:26:49 +0100 |
| commit | 9eb04373fa86068feaa3a2ed7cce7d0e4155970e (patch) | |
| tree | a21000f04bbb8d98f95adb2d47ec08e91ac2444f /runtime/test/descriptor_table_test.cpp | |
| parent | 4e390e0871d7265e629b51aca8ff99a15a6a6845 (diff) | |
Runtime: add DescriptorTable::erase() and autonomous vk_texture_test with synthetic shader
Diffstat (limited to 'runtime/test/descriptor_table_test.cpp')
| -rw-r--r-- | runtime/test/descriptor_table_test.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/runtime/test/descriptor_table_test.cpp b/runtime/test/descriptor_table_test.cpp index f9c2ba186..40cc1d159 100644 --- a/runtime/test/descriptor_table_test.cpp +++ b/runtime/test/descriptor_table_test.cpp | |||
| @@ -219,6 +219,56 @@ int test_clear_resets_table() { | |||
| 219 | return 0; | 219 | return 0; |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | int test_erase_and_cluster_compact() { | ||
| 223 | DescriptorTable table(16); | ||
| 224 | |||
| 225 | const std::uint32_t k1[8] = {1, 10, 100, 1000, 2, 20, 200, 2000}; | ||
| 226 | const std::uint32_t k2[8] = {3, 30, 300, 3000, 4, 40, 400, 4000}; | ||
| 227 | const std::uint32_t k3[8] = {5, 50, 500, 5000, 6, 60, 600, 6000}; | ||
| 228 | |||
| 229 | // Erasing a non-existent key returns false | ||
| 230 | EXPECT(!table.erase(k1)); | ||
| 231 | |||
| 232 | EXPECT(table.insert(k1, 101)); | ||
| 233 | EXPECT(table.insert(k2, 102)); | ||
| 234 | EXPECT(table.insert(k3, 103)); | ||
| 235 | EXPECT(table.size() == 3); | ||
| 236 | |||
| 237 | // Erase middle element | ||
| 238 | EXPECT(table.erase(k2)); | ||
| 239 | EXPECT(table.size() == 2); | ||
| 240 | EXPECT(!table.contains(k2)); | ||
| 241 | EXPECT(table.lookup(k2) == 0); | ||
| 242 | EXPECT(table.contains(k1)); | ||
| 243 | EXPECT(table.lookup(k1) == 101); | ||
| 244 | EXPECT(table.contains(k3)); | ||
| 245 | EXPECT(table.lookup(k3) == 103); | ||
| 246 | |||
| 247 | // Double erase returns false | ||
| 248 | EXPECT(!table.erase(k2)); | ||
| 249 | |||
| 250 | // Erase remaining entries | ||
| 251 | EXPECT(table.erase(k1)); | ||
| 252 | EXPECT(table.size() == 1); | ||
| 253 | EXPECT(!table.contains(k1)); | ||
| 254 | EXPECT(table.lookup(k1) == 0); | ||
| 255 | EXPECT(table.contains(k3)); | ||
| 256 | EXPECT(table.lookup(k3) == 103); | ||
| 257 | |||
| 258 | EXPECT(table.erase(k3)); | ||
| 259 | EXPECT(table.size() == 0); | ||
| 260 | EXPECT(!table.contains(k3)); | ||
| 261 | EXPECT(table.lookup(k3) == 0); | ||
| 262 | |||
| 263 | // Re-inserting into erased slots | ||
| 264 | EXPECT(table.insert(k1, 201)); | ||
| 265 | EXPECT(table.size() == 1); | ||
| 266 | EXPECT(table.contains(k1)); | ||
| 267 | EXPECT(table.lookup(k1) == 201); | ||
| 268 | |||
| 269 | return 0; | ||
| 270 | } | ||
| 271 | |||
| 222 | int main() { | 272 | int main() { |
| 223 | EXPECT(test_fnv1a_hash_matches_contract() == 0); | 273 | EXPECT(test_fnv1a_hash_matches_contract() == 0); |
| 224 | EXPECT(test_ssharp_key_padding() == 0); | 274 | EXPECT(test_ssharp_key_padding() == 0); |
| @@ -228,6 +278,7 @@ int main() { | |||
| 228 | EXPECT(test_gpu_buffer_serialization() == 0); | 278 | EXPECT(test_gpu_buffer_serialization() == 0); |
| 229 | EXPECT(test_multithreaded_insert_and_lookup() == 0); | 279 | EXPECT(test_multithreaded_insert_and_lookup() == 0); |
| 230 | EXPECT(test_clear_resets_table() == 0); | 280 | EXPECT(test_clear_resets_table() == 0); |
| 281 | EXPECT(test_erase_and_cluster_compact() == 0); | ||
| 231 | 282 | ||
| 232 | std::printf("descriptor_table_test: all tests passed (0 failures)\n"); | 283 | std::printf("descriptor_table_test: all tests passed (0 failures)\n"); |
| 233 | return 0; | 284 | return 0; |