GCC Code Coverage Report


./
File: tests/TestUtils.cpp
Date: 2024-08-24 11:26:06
Lines:
23/27
85.2%
Functions:
4/4
100.0%
Branches:
47/94
50.0%

Line Branch Exec Source
1 /* BEGIN software license
2 *
3 * MsXpertSuite - mass spectrometry software suite
4 * -----------------------------------------------
5 * Copyright(C) 2009,...,2024 Filippo Rusconi
6 *
7 * http://www.msxpertsuite.org
8 *
9 * This file is part of the MsXpertSuite project.
10 *
11 * The MsXpertSuite project is the successor of the massXpert project. This
12 * project now includes various independent modules:
13 *
14 * - massXpert, model polymer chemistries and simulate mass spectrometric data;
15 * - mineXpert, a powerful TIC chromatogram/mass spectrum viewer/miner;
16 *
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 *
30 * END software license
31 */
32
33
34 #include <libXpertMass/globals.hpp>
35
36 /////////////////////// Local includes
37 #include "TestUtils.hpp"
38 #include <libXpertMass/PolChemDefSpec.hpp>
39 #include <libXpertMass/PolChemDef.hpp>
40 #include <libXpertMass/Ponderable.hpp>
41 #include <libXpertMass/Formula.hpp>
42 #include <libXpertMass/Ionizable.hpp>
43
44
45 namespace MsXpS
46 {
47
48 namespace libXpertMass
49 {
50
51
52
31/62
✓ Branch 2 taken 324 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 324 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 324 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 324 times.
✗ Branch 14 not taken.
✓ Branch 17 taken 324 times.
✗ Branch 18 not taken.
✓ Branch 21 taken 324 times.
✗ Branch 22 not taken.
✓ Branch 25 taken 324 times.
✗ Branch 26 not taken.
✓ Branch 29 taken 324 times.
✗ Branch 30 not taken.
✓ Branch 33 taken 324 times.
✗ Branch 34 not taken.
✓ Branch 40 taken 324 times.
✗ Branch 41 not taken.
✓ Branch 44 taken 324 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 324 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 324 times.
✗ Branch 51 not taken.
✓ Branch 53 taken 324 times.
✗ Branch 54 not taken.
✓ Branch 56 taken 324 times.
✗ Branch 57 not taken.
✓ Branch 59 taken 324 times.
✗ Branch 60 not taken.
✓ Branch 62 taken 324 times.
✗ Branch 63 not taken.
✓ Branch 65 taken 324 times.
✗ Branch 66 not taken.
✓ Branch 70 taken 324 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 324 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 324 times.
✗ Branch 77 not taken.
✓ Branch 81 taken 324 times.
✗ Branch 82 not taken.
✓ Branch 84 taken 324 times.
✗ Branch 85 not taken.
✓ Branch 87 taken 324 times.
✗ Branch 88 not taken.
✓ Branch 92 taken 324 times.
✗ Branch 93 not taken.
✓ Branch 95 taken 324 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 324 times.
✗ Branch 99 not taken.
✓ Branch 101 taken 324 times.
✗ Branch 102 not taken.
✓ Branch 104 taken 324 times.
✗ Branch 105 not taken.
✓ Branch 107 taken 324 times.
✗ Branch 108 not taken.
✓ Branch 110 taken 324 times.
✗ Branch 111 not taken.
324 TestUtils::TestUtils()
53 {
54 324 }
55
56 648 TestUtils::~TestUtils()
57 {
58 648 }
59
60 void
61 172 TestUtils::initializeXpertmassLibrary()
62 {
63 172 configureDebugMessagesFormat();
64 172 }
65
66 PolChemDefSPtr
67 312 TestUtils::initializePolChemDef()
68 {
69
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
312 if(m_polChemDefName.isEmpty())
70 return nullptr;
71
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
312 if(m_polChemDefFileBaseName.isEmpty())
72 return nullptr;
73
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
312 if(m_polChemDefDirName.isEmpty())
74 return nullptr;
75
76
1/2
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
312 PolChemDef pol_chem_def;
77
78
1/2
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
312 pol_chem_def.setName(m_polChemDefName);
79
2/4
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
624 pol_chem_def.setXmlDataFilePath(QString("%1/%2/%3/%4")
80
1/2
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
624 .arg(m_testsInputDataDir)
81
2/4
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
624 .arg("polymer-chemistry-definitions")
82
1/2
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
624 .arg(m_polChemDefDirName)
83
1/2
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
624 .arg(m_polChemDefFileBaseName));
84
85 // qDebug() << "File path:"
86 // << QString("%1/%2/%3")
87 // .arg(m_testsInputDataDir)
88 // .arg(m_polChemDefDirName)
89 // .arg(m_polChemDefFileBaseName);
90
91
1/2
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
312 m_polChemDefSPtr = std::make_shared<PolChemDef>(pol_chem_def);
92
93
1/2
✓ Branch 3 taken 312 times.
✗ Branch 4 not taken.
312 m_isotopeCount = PolChemDef::loadIsotopicData(m_polChemDefSPtr);
94
95
2/4
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
312 if(!PolChemDef::renderXmlPolChemDefFile(m_polChemDefSPtr))
96 {
97 m_polChemDefSPtr.reset();
98 }
99
100 312 return m_polChemDefSPtr;
101 312 }
102
103
104 } // namespace libXpertMass
105 } // namespace MsXpS
106