Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
5d419d80
Commit
5d419d80
authored
Sep 10, 2021
by
Nguyen, Thien Minh
Browse files
Added checks for the graph data
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
3235881e
Changes
1
Hide whitespace changes
Inline
Side-by-side
quantum/gate/utils/tests/IRToGraphVisitorTester.cpp
View file @
5d419d80
...
...
@@ -44,6 +44,23 @@ TEST(IRToGraphTester, checkSimple) {
auto
graph
=
vis
->
getGraph
();
graph
->
write
(
std
::
cout
);
EXPECT_EQ
(
graph
->
order
(),
f
->
nInstructions
()
+
2
);
// X and H are on the first layer
EXPECT_EQ
(
graph
->
getVertexProperties
(
1
).
getString
(
"name"
),
x
->
name
());
EXPECT_EQ
(
graph
->
getVertexProperties
(
1
).
get
<
int
>
(
"layer"
),
0
);
EXPECT_EQ
(
graph
->
getVertexProperties
(
2
).
getString
(
"name"
),
h
->
name
());
EXPECT_EQ
(
graph
->
getVertexProperties
(
2
).
get
<
int
>
(
"layer"
),
0
);
// CNOT on the second layer
EXPECT_EQ
(
graph
->
getVertexProperties
(
3
).
getString
(
"name"
),
"CNOT"
);
EXPECT_EQ
(
graph
->
getVertexProperties
(
3
).
get
<
int
>
(
"layer"
),
1
);
// Rz and Z on the third layer
EXPECT_EQ
(
graph
->
getVertexProperties
(
4
).
getString
(
"name"
),
rz
->
name
());
EXPECT_EQ
(
graph
->
getVertexProperties
(
4
).
get
<
int
>
(
"layer"
),
2
);
EXPECT_EQ
(
graph
->
getVertexProperties
(
5
).
getString
(
"name"
),
z
->
name
());
EXPECT_EQ
(
graph
->
getVertexProperties
(
5
).
get
<
int
>
(
"layer"
),
2
);
}
TEST
(
IRToGraphTester
,
checkCNOTLadder
)
{
...
...
@@ -69,6 +86,12 @@ TEST(IRToGraphTester, checkCNOTLadder) {
auto
graph
=
vis
->
getGraph
();
graph
->
write
(
std
::
cout
);
// These CNOT gates cannot be on the same layer.
for
(
int
i
=
1
;
i
<
graph
->
order
()
-
2
;
i
++
)
{
auto
node
=
graph
->
getVertexProperties
(
i
);
EXPECT_EQ
(
node
.
getString
(
"name"
),
"CNOT"
);
EXPECT_EQ
(
node
.
get
<
int
>
(
"layer"
),
i
-
1
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment