OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
7BOOST_AUTO_TEST_SUITE( csv_writer_test )
8
9
10BOOST_AUTO_TEST_CASE( csv_writer_particles )
11{
12 Vcluster<> & v_cl = create_vcluster();
13
14 if (v_cl.getProcessUnitID() != 0)
15 return;
16
17#ifdef OPENFPM_PDATA
18
19 if (v_cl.rank() != 0) {return;}
20 std::string c2 = std::string("openfpm_io/test_data/csv_out_test.csv");
21 std::string c3 = std::string("openfpm_io/test_data/csv_out_unk_test.csv");
22
23
24#else
25
26 std::string c2 = std::string("test_data/csv_out_test.csv");
27 std::string c3 = std::string("test_data/csv_out_unk_test.csv");
28
29#endif
30
31 {
32 // Allocate a property vector
33 auto v_prp = allocate_openfpm_prp(16);
34 // Vector of position
36
37 // create a positional vector
38 for (size_t i = 0 ; i < v_prp.size() ; i++)
39 {
40 Point<3,float> p({1.0,2.0,3.0});
41
42 v_pos.add(p);
43 }
44
45 // CSVWriter test
47
48 // Write the CSV
49 csv_writer.write("csv_out.csv",v_pos,v_prp);
50
51 bool test = compare("csv_out.csv",c2);
52 BOOST_REQUIRE_EQUAL(true,test);
53 }
54
55 {
56 // Allocate a property vector
57 auto v_prp = allocate_openfpm_aggregate_with_complex(16);
58 // Vector of position
60
61 // create a positional vector
62 for (size_t i = 0 ; i < v_prp.size() ; i++)
63 {
64 Point<3,float> p({1.0,2.0,3.0});
65
66 v_pos.add(p);
67 }
68
69 // CSVWriter test
71
72 // Write the CSV
73 csv_writer.write("csv_out_unk.csv",v_pos,v_prp);
74
75 // In case of SE_CLASS3 enabled the number of properties change
76
77#ifndef SE_CLASS3
78 bool test = compare("csv_out_unk.csv",c3);
79 BOOST_REQUIRE_EQUAL(true,test);
80#endif
81 }
82
83}
84
85BOOST_AUTO_TEST_SUITE_END()
86
87#endif
CSV Writer.
bool write(std::string file, v_pos &v, v_prp &prp, size_t offset=0)
It write a CSV file.
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
size_t rank()
Get the process unit id.
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
Definition VCluster.hpp:59
Implementation of 1-D std::vector like structure.