GCC Code Coverage Report


Directory: ./
File: Gate/OpPtrFunctions.cpp
Date: 2022-10-15 05:10:18
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 2 2 100.0%
Branches: 7 12 58.3%
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 "OpPtrFunctions.hpp"
16
17 #include "Gate.hpp"
18 #include "Ops/MetaOp.hpp"
19 #include "SymTable.hpp"
20
21 namespace tket {
22
23 314568 Op_ptr get_op_ptr(OpType chosen_type, const Expr& param, unsigned n_qubits) {
24
4/8
✓ Branch 3 taken 314568 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 314568 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 314568 times.
✓ Branch 11 taken 314568 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
943704 return get_op_ptr(chosen_type, std::vector<Expr>{param}, n_qubits);
25 }
26
27 2002201 Op_ptr get_op_ptr(
28 OpType chosen_type, const std::vector<Expr>& params, unsigned n_qubits) {
29
2/2
✓ Branch 1 taken 1232799 times.
✓ Branch 2 taken 769402 times.
2/2
✓ Decision 'true' taken 1232799 times.
✓ Decision 'false' taken 769402 times.
2002201 if (is_gate_type(chosen_type)) {
30
1/2
✓ Branch 2 taken 1232799 times.
✗ Branch 3 not taken.
1232799 SymTable::register_symbols(expr_free_symbols(params));
31 1232799 return std::make_shared<const Gate>(chosen_type, params, n_qubits);
32 } else {
33 769402 return std::make_shared<const MetaOp>(chosen_type);
34 }
35 }
36
37 } // namespace tket
38