1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57/*
* Vool - Unit tests for GNP, as it will open a pipe to an external application, testability is limited
*
* Copyright (c) 2016 Lukas Bergdoll - www.lukas-bergdoll.net
*
* This code is licensed under the Apache License 2.0 (https://opensource.org/licenses/Apache-2.0)
*/
#include "AllTests.h"
#include <GNP.h>
#include <vector>
#include <string>
#include <exception>
namespace vool
{
namespace tests
{
void test_GNP()
{
gnuplot::filepath_t gnuplot_filepath = "C:\\ProgramData\\gnuplot\\bin\\gnuplot";
std::string cat = gnuplot_util::concatenate("cat ", 1, 2.f, " ", 3.3, " man");
if (cat != "cat 12.000000 3.300000 man")
throw std::exception("convert_to_string_v error");
gnuplot gnp(gnuplot_filepath);
gnp("set samples 10");
gnp("set samples ", 150);
gnp.name_axis("A", "B");
gnp.set_terminal_window(1200, 500);
gnp.add_linestyle(1, "#FF5A62", 2, 3, 5, 1.5f);
gnp.add_grid();
gnp("plot sin(x) ls 1"); // test plot, should open window and close it again
gnp.set_terminal_png(1200, 500);
gnp.set_png_filename("TestGraph");
gnp("plot sin(x) ls 1"); // should save TestGraph.png in source directory
gnp.set_png_filename("TestDataPlot");
std::vector<std::pair<double, double>> dataPoints = { {1,4}, {3,2}, {4,7} };
std::vector<plot_data_2D<double>> plot;
plot.emplace_back(dataPoints, 0, "Test Points");
gnp.write_and_plot(plot, "data\\GNPTestData.dat");
}
}
}