-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate_test.cpp
73 lines (61 loc) · 2.04 KB
/
state_test.cpp
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
/*
Copyright (C) Université Pierre et Marie Curie (2017)
Contributor: Alexis Poncet <[email protected]>
This file is part of ForceInCrystal.
ForceInCrystal is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ForceInCrystal is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ForceInCrystal. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file simul.cpp
* \author Alexis Poncet <[email protected]>
* \version 1.0
* \date 2017-11-28
* \brief Unit testing for state.cpp
*/
#define BOOST_TEST_MODULE My Test
#include <boost/test/included/unit_test.hpp>
#include "state.h"
//! Test of pbc(x, L)
BOOST_AUTO_TEST_CASE(pbc_test)
{
double a = 0.105, x = 2.105, y = 10.105, z = -1.895;
pbc(a, 2.0);
pbc(x, 2.0);
pbc(y, 2.0);
pbc(z, 2.0);
BOOST_CHECK_CLOSE(a, 0.105, 1e-5);
BOOST_CHECK_CLOSE(x, 0.105, 1e-5);
BOOST_CHECK_CLOSE(y, 0.105, 1e-5);
BOOST_CHECK_CLOSE(z, 0.105, 1e-5);
}
//! Test of pbcHex(x, y, L1, L2)
BOOST_AUTO_TEST_CASE(pbc_hex_test)
{
double L1 = 3.0, L2 = 2.0;
double x, y;
x = 2.0; y = 1.0;
pbcHex(x, y, L1, L2);
BOOST_CHECK_CLOSE(x, 2.0, 1e-5); BOOST_CHECK_CLOSE(y, 1.0, 1e-5);
x = 4.0; y = 1.0;
pbcHex(x, y, L1, L2);
BOOST_CHECK_CLOSE(x, 1.0, 1e-5); BOOST_CHECK_CLOSE(y, 1.0, 1e-5);
x = -5.0; y = 1.0;
pbcHex(x, y, L1, L2);
BOOST_CHECK_CLOSE(x, 1.0, 1e-5); BOOST_CHECK_CLOSE(y, 1.0, 1e-5);
x = 2.0; y = 2.0;
pbcHex(x, y, L1, L2);
BOOST_CHECK_CLOSE(x, 2.0 - L2 * 0.5, 1e-5);
BOOST_CHECK_CLOSE(y, 2.0 - L2 * 0.86602540378443864676, 1e-5);
x = 1.0; y = -1.0;
pbcHex(x, y, L1, L2);
BOOST_CHECK_CLOSE(x, 1.0 + L2 * 0.5, 1e-5);
BOOST_CHECK_CLOSE(y, -1.0 + L2 * 0.86602540378443864676, 1e-5);
}