MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / TEST_F

Function TEST_F

unittests/Optimizer/DecompositionPatternsTest.cpp:295–324  ·  view source on GitHub ↗

Test 2: Verify pattern names match getDebugName()

Source from the content-addressed store, hash-verified

293
294// Test 2: Verify pattern names match getDebugName()
295TEST_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)
327TEST_F(DecompositionPatternsTest, MetadataConsistency) {

Callers

nothing calls this directly

Calls 15

stripNamespaceFunction · 0.85
createTestModuleFunction · 0.85
applySinglePatternFunction · 0.85
collectGateTypesInModuleFunction · 0.85
splitGateAndControlsFunction · 0.85
getNameMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
strMethod · 0.45
instantiateMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected