GCC Code Coverage Report


Directory: ./
File: Gate/GatePtr.cpp
Date: 2022-10-15 05:10:18
Exec Total Coverage
Lines: 6 6 100.0%
Functions: 1 1 100.0%
Branches: 4 6 66.7%
Decisions: 2 2 100.0%

Line Branch Decision Exec Source
1 // Copyright 2019-2022 Cambridge Quantum Computing
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "GatePtr.hpp"
16
17 #include <memory>
18
19 #include "Gate.hpp"
20 #include "OpType/OpTypeInfo.hpp"
21 #include "Ops/OpPtr.hpp"
22
23 namespace tket {
24
25 826581 Gate_ptr as_gate_ptr(Op_ptr op) {
26 826581 Gate_ptr gp = std::dynamic_pointer_cast<const Gate>(op);
27
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 826580 times.
2/2
✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 826580 times.
826581 if (!gp) {
28
2/4
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 throw BadOpType("Operation is not a gate", op->get_type());
29 }
30 826580 return gp;
31 1 }
32
33 } // namespace tket
34