This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 919
/
MultiTargetCNOTTests.qs
43 lines (37 loc) · 1.78 KB
/
MultiTargetCNOTTests.qs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Samples.UnitTesting {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Diagnostics;
///////////////////////////////////////////////////////////////////////////////////////////////
// Unit test for circuits implementing Multi Target Multiply Controlled Not gates
///////////////////////////////////////////////////////////////////////////////////////////////
/// # Summary
/// Tests correctness of MultiTargetMultiNot implementations
@Test("QuantumSimulator")
operation CheckMultiTargetMultiControlledNotIsCorrect() : Unit {
// list of the operations to test in format (actual, expected)
let testList = [
(ApplyMultiTargetMultiNot, Controlled (ApplyToEachCA(X, _)))
];
for (actual, expected) in testList {
for totalNumberOfQubits in 1 .. 8 {
// We use AssertOperationsEqualReferenced as it requires only
// one call to the operation being tested
// when the number of controls is one
// the test will cover MultiTargetNot function
for numberOfControls in 1 .. totalNumberOfQubits - 1 {
Message(
$"Testing {actual} against {expected} " +
$"on {totalNumberOfQubits} with {numberOfControls} controls."
);
AssertOperationsEqualReferenced(totalNumberOfQubits,
ApplyToPartitionCA(actual, numberOfControls, _),
ApplyToPartitionCA(expected, numberOfControls, _)
);
}
}
}
}
}