forked from microsoft/Quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeleportationTests.qs
More file actions
39 lines (34 loc) · 1.27 KB
/
TeleportationTests.qs
File metadata and controls
39 lines (34 loc) · 1.27 KB
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Samples.UnitTesting {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Primitive;
open Microsoft.Quantum.Extensions.Testing;
/// # Summary
/// If the Teleportation circuit is correct this operation must be an identity
operation TeleportationIdentityTestHelper (arg : Qubit[]) : () {
body {
AssertIntEqual(Length(arg), 1, "Helper is defined only on single qubit input");
using (anc = Qubit[1])
{
Teleportation(arg[0], anc[0]);
SWAP(arg[0], anc[0]);
}
}
}
/// # Summary
/// Tests the correctness of the teleportation circuit from Teleportation.qs
operation TeleportationTest () : () {
body {
// given that there is randomness involved in the Teleportation,
// repeat the tests several times.
for(idxIteration in 1 .. 8)
{
AssertOperationsEqualInPlace(
TeleportationIdentityTestHelper, NoOp, 1);
AssertOperationsEqualReferenced(
TeleportationIdentityTestHelper, NoOp, 1);
}
}
}
}