QMCPACK
test_particle_attrib.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
8 //
9 // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include "Message/Communicate.h"
16 #include "OhmmsPETE/OhmmsMatrix.h"
17 #include "OhmmsPETE/TinyVector.h"
18 #include "Lattice/CrystalLattice.h"
20 
21 #include <stdio.h>
22 #include <string>
23 
24 using std::string;
25 
26 namespace qmcplusplus
27 {
28 TEST_CASE("particle_attrib_scalar", "[particle_base]")
29 {
31  REQUIRE(PA1.size() == 0);
32 
33  PA1.resize(4);
34  REQUIRE(PA1.size() == 4);
35 
37  REQUIRE(PA3.size() == 3);
38 
39  REQUIRE(PA3[0] == 0.0);
40  // Whole array operation
41  PA3 = 1.0;
42  REQUIRE(PA3[0] == 1.0);
43  REQUIRE(PA3[1] == 1.0);
44  REQUIRE(PA3[2] == 1.0);
45 
46  // Single element
47  PA3[0] = 2.0;
48  REQUIRE(PA3[0] == 2.0);
49  REQUIRE(PA3[1] == 1.0);
50 }
51 
52 TEST_CASE("particle_attrib_vector", "[particle_base]")
53 {
55  REQUIRE(PA1.size() == 0);
56 
57  PA1.resize(3);
58  REQUIRE(PA1.size() == 3);
59 
60  PA1[0] = 1.0;
61  PA1[1] = 0.0;
62  REQUIRE(PA1[0][0] == 1.0);
63  REQUIRE(PA1[0][1] == 1.0);
64  REQUIRE(PA1[1][0] == 0.0);
65 }
66 
67 } // namespace qmcplusplus
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
Attaches a unit to a Vector for IO.
Declaration of CrystalLattice<T,D>
size_type size() const
return the current size
Definition: OhmmsVector.h:162
REQUIRE(std::filesystem::exists(filename))
Declaraton of ParticleAttrib<T> derived from Vector.