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 {
18 // Allocate a property vector
19 auto v_prp = allocate_openfpm_prp(16);
20 // Vector of position
21 openfpm::vector<Point<3,float>> v_pos;
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
32 CSVWriter<openfpm::vector<Point<3,float>>, openfpm::vector<Point_test_prp<float>> > csv_writer;
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
45 openfpm::vector<Point<3,float>> v_pos;
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
56 CSVWriter<openfpm::vector<Point<3,float>>, openfpm::vector< aggregate<float,float,float,float,float[3],float[3][3],openfpm::vector<int>> > > csv_writer;
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
71BOOST_AUTO_TEST_SUITE_END()
72
73#endif
74