forked from microsoft/Quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiTargetCNOTTests.qs
42 lines (31 loc) · 1.77 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Samples.UnitTesting {
open Microsoft.Quantum.Primitive;
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Extensions.Testing;
///////////////////////////////////////////////////////////////////////////////////////////////
// Unit test for circuits implementing Multi Target Multiply Controlled Not gates
///////////////////////////////////////////////////////////////////////////////////////////////
/// # Summary
/// Tests correctness of MultiTargetMultiNot implementations
operation MultiTargetMultiControlledNotTest () : Unit {
// list of the operations to test in format (actual,expected)
let testList = [(MultiTargetMultiNot, Controlled MultiX)];
for (i in 0 .. Length(testList) - 1) {
let (actual, expected) = testList[i];
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) {
let msg1 = $"Testing {actual} against {expected} ";
let msg2 = $" on {totalNumberOfQubits} with {numberOfControls} controls";
Message(msg1 + msg2);
AssertOperationsEqualReferenced(ApplyToPartitionCA(actual, numberOfControls, _), ApplyToPartitionCA(expected, numberOfControls, _), totalNumberOfQubits);
}
}
}
}
}