Line |
Branch |
Exec |
Source |
1 |
|
|
// ./tests/catch2-tests [section] -s |
2 |
|
|
|
3 |
|
|
|
4 |
|
|
/////////////////////// Qt includes |
5 |
|
|
#include <QDebug> |
6 |
|
|
#include <QString> |
7 |
|
|
#include <QDir> |
8 |
|
|
|
9 |
|
|
/////////////////////// IsoSpec |
10 |
|
|
#include <IsoSpec++/isoSpec++.h> |
11 |
|
|
#include <IsoSpec++/element_tables.h> |
12 |
|
|
|
13 |
|
|
|
14 |
|
|
/////////////////////// Catch2 includes |
15 |
|
|
#include <catch2/catch_test_macros.hpp> |
16 |
|
|
#include <catch2/catch_approx.hpp> |
17 |
|
|
|
18 |
|
|
|
19 |
|
|
/////////////////////// Local includes |
20 |
|
|
#include "tests-config.h" |
21 |
|
|
#include <libXpertMass/Isotope.hpp> |
22 |
|
|
#include <libXpertMass/IsotopicDataLibraryHandler.hpp> |
23 |
|
|
|
24 |
|
|
namespace MsXpS |
25 |
|
|
{ |
26 |
|
|
|
27 |
|
|
namespace libXpertMass |
28 |
|
|
{ |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
IsotopicDataLibraryHandler iso_data_lib_handler; |
32 |
|
|
|
33 |
|
|
|
34 |
|
12 |
SCENARIO("IsotopicDataLibraryHandler loads data from IsoSpec++'s tables") |
35 |
|
|
{ |
36 |
|
|
|
37 |
8/14
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 12 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 12 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✓ Branch 24 taken 8 times.
|
12 |
WHEN("Constructed, the data are empty") |
38 |
|
|
{ |
39 |
|
|
|
40 |
7/14
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
|
4 |
THEN("The isotopic data are empty but they are allocated") |
41 |
|
|
{ |
42 |
6/16
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
4 |
REQUIRE(iso_data_lib_handler.getIsotopicData() != nullptr); |
43 |
|
4 |
} |
44 |
|
12 |
} |
45 |
|
|
|
46 |
8/14
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 12 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 12 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✓ Branch 24 taken 8 times.
|
12 |
AND_WHEN("Loading isotopic data from library") |
47 |
|
|
{ |
48 |
|
4 |
std::size_t non_isotope_skipped_items = 0; |
49 |
|
|
std::size_t loaded_isotope_count = |
50 |
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 |
iso_data_lib_handler.loadData(non_isotope_skipped_items); |
51 |
|
|
|
52 |
7/14
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
|
4 |
THEN("The number of isotopes loaded is checked") |
53 |
|
|
{ |
54 |
5/14
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
4 |
REQUIRE(loaded_isotope_count + non_isotope_skipped_items == |
55 |
|
|
IsoSpec::isospec_number_of_isotopic_entries); |
56 |
7/18
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✓ Branch 25 taken 4 times.
✗ Branch 26 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
|
4 |
REQUIRE(iso_data_lib_handler.getIsotopicData()->size() == |
57 |
|
|
loaded_isotope_count); |
58 |
|
4 |
} |
59 |
|
12 |
} |
60 |
|
|
|
61 |
8/14
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 12 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 12 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✓ Branch 24 taken 8 times.
|
12 |
AND_WHEN("A new IsotopicDataLibraryHandler instance is copy constructed") |
62 |
|
|
{ |
63 |
|
|
long use_count_before_copy = |
64 |
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 |
iso_data_lib_handler.getIsotopicData().use_count(); |
65 |
|
|
|
66 |
|
4 |
IsotopicDataLibraryHandler iso_data_lib_handler_1(iso_data_lib_handler); |
67 |
|
|
|
68 |
7/14
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
|
4 |
THEN("The instances are checked and should be identical") |
69 |
|
|
{ |
70 |
9/22
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 4 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 4 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✓ Branch 33 taken 4 times.
✗ Branch 34 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
|
4 |
REQUIRE(iso_data_lib_handler.getIsotopicData()->size() == |
71 |
|
|
iso_data_lib_handler_1.getIsotopicData()->size()); |
72 |
|
|
|
73 |
|
|
long use_count_after_copy = |
74 |
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 |
iso_data_lib_handler.getIsotopicData().use_count(); |
75 |
|
|
|
76 |
5/14
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
4 |
REQUIRE(use_count_after_copy == use_count_before_copy + 1); |
77 |
|
4 |
} |
78 |
|
16 |
} |
79 |
|
12 |
} |
80 |
|
|
|
81 |
|
8 |
SCENARIO("IsotopicDataLibraryHandler writes data to file") |
82 |
|
|
{ |
83 |
|
|
|
84 |
7/14
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 8 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 8 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 8 times.
✗ Branch 24 not taken.
|
8 |
WHEN("Data have been loaded, the data are checked") |
85 |
|
|
{ |
86 |
|
8 |
std::size_t non_isotope_skipped_items = 0; |
87 |
|
|
std::size_t loaded_isotope_count = |
88 |
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 |
iso_data_lib_handler.loadData(non_isotope_skipped_items); |
89 |
|
|
|
90 |
8/14
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 8 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 8 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✓ Branch 24 taken 4 times.
|
8 |
THEN("The number of isotopes loaded is checked") |
91 |
|
|
{ |
92 |
5/14
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
4 |
REQUIRE(loaded_isotope_count + non_isotope_skipped_items == |
93 |
|
|
IsoSpec::isospec_number_of_isotopic_entries); |
94 |
7/18
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✓ Branch 25 taken 4 times.
✗ Branch 26 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
|
4 |
REQUIRE(iso_data_lib_handler.getIsotopicData()->size() == |
95 |
|
|
loaded_isotope_count); |
96 |
|
8 |
} |
97 |
|
|
|
98 |
8/14
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 8 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 8 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✓ Branch 24 taken 4 times.
|
8 |
AND_WHEN("Isotopic data are written to file") |
99 |
|
|
{ |
100 |
|
|
QString isotopes_output_dir = |
101 |
5/10
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
|
12 |
QString("%1/%2").arg(TESTS_OUTPUT_DIR).arg("isotopes"); |
102 |
|
|
|
103 |
1/2
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 |
QDir dir; |
104 |
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 |
bool result = dir.mkpath(isotopes_output_dir); |
105 |
5/14
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
4 |
REQUIRE(result == true); |
106 |
|
|
|
107 |
|
|
QString output_file_name = |
108 |
4/8
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
12 |
QString("%1/%2").arg(isotopes_output_dir).arg("isospec-tables.dat"); |
109 |
|
|
|
110 |
|
|
// qDebug() << "The write file name: " << output_file_name.toStdString() << std::endl; |
111 |
|
|
|
112 |
|
|
std::size_t written_isotope_count = |
113 |
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 |
iso_data_lib_handler.writeData(output_file_name); |
114 |
|
|
|
115 |
7/14
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
|
4 |
THEN("The count of written isotopes is checked") |
116 |
|
|
{ |
117 |
5/14
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
4 |
REQUIRE(written_isotope_count == loaded_isotope_count); |
118 |
|
4 |
} |
119 |
|
12 |
} |
120 |
|
8 |
} |
121 |
|
8 |
} |
122 |
|
|
|
123 |
|
|
|
124 |
|
|
} // namespace libXpertMass |
125 |
|
|
} // namespace MsXpS |
126 |
|
|
|