[go: up one dir, main page]

Menu

[d23a0d]: / tests / atoms.cpp  Maximize  Restore  History

Download this file

56 lines (43 with data), 1.4 kB

 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
#include <catch.hpp>
#include "chemfiles.hpp"
#include "chemfiles/Atom.hpp"
using namespace chemfiles;
TEST_CASE("Use the Atom type", "[Atoms]"){
Atom a1("H");
Atom a2 = Atom();
Atom a3(Atom::COARSE_GRAINED, "CH4");
Atom a4("W");
SECTION("Check constructors"){
CHECK(a1.name() == "H");
CHECK(a1.mass() == 1.008f);
CHECK(a1.type() == Atom::ELEMENT);
CHECK(a1.charge() == 0);
CHECK(a2.type() == Atom::UNDEFINED);
CHECK(a2.name() == "");
CHECK(a2.mass() == 0);
CHECK(a2.charge() == 0);
CHECK(a3.type() == Atom::COARSE_GRAINED);
CHECK(a3.name() == "CH4");
CHECK(a3.mass() == 0);
CHECK(a3.charge() == 0);
}
SECTION("Set and get properties"){
a1.set_type(Atom::DUMMY);
CHECK(a1.type() == Atom::DUMMY);
a1.set_mass(14.789f);
CHECK(a1.mass() == 14.789f);
a1.set_charge(-2);
CHECK(a1.charge() == -2);
a1.set_name("foo");
CHECK(a1.name() == "foo");
CHECK(a4.mass() == 183.84f);
CHECK(a4.atomic_number() == 74);
CHECK(a4.full_name() == "Tungsten");
CHECK(a4.covalent_radius() == 1.46f);
CHECK(a4.vdw_radius() == 2.1f);
CHECK(a3.atomic_number() == -1);
CHECK(a3.full_name() == "");
CHECK(a3.covalent_radius() == -1.0f);
CHECK(a3.vdw_radius() == -1.0f);
}
}