OpenFPM  5.2.0
Project that contain the implementation of distributed structures
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  std::string c2 = std::string("test_data/csv_out_test.csv");
18  std::string c3 = std::string("test_data/csv_out_unk_test.csv");
19 
20  {
21  // Allocate a property vector
22  auto v_prp = allocate_openfpm_prp(16);
23  // Vector of position
25 
26  // create a positional vector
27  for (size_t i = 0 ; i < v_prp.size() ; i++)
28  {
29  Point<3,float> p({1.0,2.0,3.0});
30 
31  v_pos.add(p);
32  }
33 
34  // CSVWriter test
36 
37  // Write the CSV
38  csv_writer.write("csv_out.csv",v_pos,v_prp);
39 
40  bool test = compare("csv_out.csv",c2);
41  BOOST_REQUIRE_EQUAL(true,test);
42  }
43 
44  {
45  // Allocate a property vector
46  auto v_prp = allocate_openfpm_aggregate_with_complex(16);
47  // Vector of position
49 
50  // create a positional vector
51  for (size_t i = 0 ; i < v_prp.size() ; i++)
52  {
53  Point<3,float> p({1.0,2.0,3.0});
54 
55  v_pos.add(p);
56  }
57 
58  // CSVWriter test
60 
61  // Write the CSV
62  csv_writer.write("csv_out_unk.csv",v_pos,v_prp);
63 
64  // In case of SE_CLASS3 enabled the number of properties change
65 
66 #ifndef SE_CLASS3
67  bool test = compare("csv_out_unk.csv",c3);
68  BOOST_REQUIRE_EQUAL(true,test);
69 #endif
70  }
71 
72 }
73 
74 BOOST_AUTO_TEST_SUITE_END()
75 
76 #endif
CSV Writer.
Definition: CSVWriter.hpp:164
bool write(std::string file, v_pos &v, v_prp &prp, size_t offset=0)
It write a CSV file.
Definition: CSVWriter.hpp:248
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
Definition: VCluster.hpp:59
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:204