OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
CSVWriter_unit_tests.hpp
1 #ifndef CSVWRITER_UNIT_TESTS_HPP_
2 #define CSVWRITER_UNIT_TESTS_HPP_
3 
4 #include "CSVWriter.hpp"
5 #include "Vector/vector_test_util.hpp"
6 
7 BOOST_AUTO_TEST_SUITE( csv_writer_test )
8 
9 
10 BOOST_AUTO_TEST_CASE( csv_writer_particles )
11 {
12  Vcluster & v_cl = create_vcluster();
13 
14  if (v_cl.getProcessUnitID() != 0)
15  return;
16 
17  {
18  // Allocate a property vector
19  auto v_prp = allocate_openfpm_prp(16);
20  // Vector of position
22 
23  // create a positional vector
24  for (size_t i = 0 ; i < v_prp.size() ; i++)
25  {
26  Point<3,float> p({1.0,2.0,3.0});
27 
28  v_pos.add(p);
29  }
30 
31  // CSVWriter test
33 
34  // Write the CSV
35  csv_writer.write("csv_out.csv",v_pos,v_prp);
36 
37  bool test = compare("csv_out.csv","test_data/csv_out_test.csv");
38  BOOST_REQUIRE_EQUAL(true,test);
39  }
40 
41  {
42  // Allocate a property vector
43  auto v_prp = allocate_openfpm_aggregate_with_complex(16);
44  // Vector of position
46 
47  // create a positional vector
48  for (size_t i = 0 ; i < v_prp.size() ; i++)
49  {
50  Point<3,float> p({1.0,2.0,3.0});
51 
52  v_pos.add(p);
53  }
54 
55  // CSVWriter test
57 
58  // Write the CSV
59  csv_writer.write("csv_out_unk.csv",v_pos,v_prp);
60 
61  // In case of SE_CLASS3 enabled the number of properties change
62 
63 #ifndef SE_CLASS3
64  bool test = compare("csv_out_unk.csv","test_data/csv_out_unk_test.csv");
65  BOOST_REQUIRE_EQUAL(true,test);
66 #endif
67  }
68 
69 }
70 
71 BOOST_AUTO_TEST_SUITE_END()
72 
73 #endif
size_t getProcessUnitID()
Get the process unit id.
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
CSV Writer.
Definition: CSVWriter.hpp:163
Implementation of VCluster class.
Definition: VCluster.hpp:36
bool write(std::string file, v_pos &v, v_prp &prp, size_t offset=0)
It write a CSV file.
Definition: CSVWriter.hpp:248
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61