Test 2: Verify pattern names match getDebugName()
| 293 | |
| 294 | // Test 2: Verify pattern names match getDebugName() |
| 295 | TEST_F(DecompositionPatternsTest, PatternNamesMatchDebugNames) { |
| 296 | auto patternEntries = cudaq::DecompositionPatternTypeRegistry::entries(); |
| 297 | |
| 298 | for (auto &entry : patternEntries) { |
| 299 | std::string patternName = entry.getName().str(); |
| 300 | std::unique_ptr<cudaq::DecompositionPatternType> patternType; |
| 301 | for (auto it = cudaq::DecompositionPatternType::RegistryType::begin(), |
| 302 | ie = cudaq::DecompositionPatternType::RegistryType::end(); |
| 303 | it != ie; ++it) { |
| 304 | if (patternName == it->getName()) { |
| 305 | patternType = it->instantiate(); |
| 306 | break; |
| 307 | } |
| 308 | } |
| 309 | ASSERT_NE(patternType, nullptr) |
| 310 | << "Failed to recover registered pattern type: " << patternName; |
| 311 | |
| 312 | auto pattern = patternType->create(context.get()); |
| 313 | ASSERT_NE(pattern, nullptr) << "Failed to create pattern: " << patternName; |
| 314 | |
| 315 | // Get the debug name |
| 316 | auto debugName = pattern->getDebugName().str(); |
| 317 | stripNamespace(debugName); |
| 318 | |
| 319 | // Verify they match |
| 320 | EXPECT_EQ(patternName, debugName) |
| 321 | << "Pattern name '" << patternName << "' does not match debug name '" |
| 322 | << debugName << "'"; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // Test 3: Verify metadata is consistent (source and target gates are valid) |
| 327 | TEST_F(DecompositionPatternsTest, MetadataConsistency) { |
nothing calls this directly
no test coverage detected