-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.h
90 lines (61 loc) · 1.65 KB
/
tests.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef TESTS_H
#define TESTS_H
#include <vector>
#include <string>
#include "db_worker.h"
#include "tester.h"
#include "formula_parser.h"
#include <QString>
void TestFindEquivalent(DBWorker *db){
std::vector<std::string> formuls {
"ZnCl2",
"KHCO3",
"Al2(CO3)3",
"Al(HCO3)3",
"(MgOH)2SO4"
};
std::vector<float> results;
for (const auto& formula : formuls) {
results.push_back(db->FindEquivalent(QString::fromStdString(formula)));
}
std::vector<float> comparation{2, 3, 6, 3, 8};
for (size_t i = 0; i < comparation.size(); ++i) {
ASSERT_EQUAL(comparation[i], results[i]);
}
}
void TestParse() {
std::vector<std::string> formuls{
"HCO3-",
"HC5H5N+",
"[Cu(H2O)4]SO4*0.5H2O",
"[Cu(H2O)4]SO4*H2O",
"Cu(NO3)2*6H2O",
"Co3(Fe(CN)6)2",
"(NH4)2[Pt(SCN)6]",
"(NH4)2Hg(SCN)4",
"C4H11NO3*HCl",
"C18H36N4O11*H2SO4*H2O"
};
std::vector<float> results;
QString error;
for (const auto& formula : formuls) {
QString tmp = QString::fromStdString(formula);
results.push_back(ConvertToMolecularWeight(tmp, error));
}
std::vector<std::string> comparation{
"61.0159",
"66.1026",
"240.675",
"249.682",
"295.643",
"600.709",
"579.661",
"469.004",
"157.596",
"600.594"
};
for (size_t i = 0; i < comparation.size(); ++i) {
//ASSERT_EQUAL(comparation[i], results[i]);
}
}
#endif // TESTS_H