1 | // $Id: graph.cc 1188 2010-09-01 01:28:19Z peter $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2010 Jari Häkkinen, Peter Johansson |
---|
5 | |
---|
6 | This file is part of svndigest, http://dev.thep.lu.se/svndigest |
---|
7 | |
---|
8 | svndigest is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 3 of the License, or |
---|
11 | (at your option) any later version. |
---|
12 | |
---|
13 | svndigest is distributed in the hope that it will be useful, but |
---|
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | */ |
---|
21 | |
---|
22 | #include "Suite.h" |
---|
23 | |
---|
24 | #include "lib/Graph.h" |
---|
25 | #include "lib/Vector.h" |
---|
26 | |
---|
27 | #include <cstdlib> |
---|
28 | #include <ostream> |
---|
29 | |
---|
30 | using namespace theplu::svndigest; |
---|
31 | |
---|
32 | void test_graph(const std::string format, test::Suite& suite); |
---|
33 | void test_graph__(const std::string format, test::Suite& suite); |
---|
34 | |
---|
35 | int main(int argc, char* argv[]) |
---|
36 | { |
---|
37 | test::Suite suite(argc, argv); |
---|
38 | |
---|
39 | #ifndef HAVE_PLPLOT |
---|
40 | suite.out() << "no plplot: skip test\n"; |
---|
41 | exit(EXIT_SKIP); |
---|
42 | #endif |
---|
43 | |
---|
44 | test_graph("svg", suite); |
---|
45 | // Need to create an instance of Graph (plstream) since there is a |
---|
46 | // bug in plplot with dynamic loading of runtime libraries. The |
---|
47 | // issue is reported in the plplot issue tracking system |
---|
48 | // https://sf.net/tracker/?func=detail&aid=3009045&group_id=2915&atid=102915 |
---|
49 | // and as http://dev.thep.lu.se/svndigest/ticket/472. Simply remove |
---|
50 | // this comment and the next line of code when plplot developers |
---|
51 | // fixes their bug. |
---|
52 | // |
---|
53 | // Omitting the dummy instance will cause segmentation fault. |
---|
54 | Graph dummy_never_used("/dev/null", "png"); |
---|
55 | test_graph("png", suite); |
---|
56 | test_graph("pdf", suite); |
---|
57 | |
---|
58 | return suite.exit_status(); |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | void test_graph(const std::string format, test::Suite& suite) |
---|
63 | { |
---|
64 | suite.out() << "testing " << format << std::endl; |
---|
65 | for (size_t i=0; i<20; ++i) |
---|
66 | test_graph__(format, suite); |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | void test_graph__(const std::string format, test::Suite& suite) |
---|
71 | { |
---|
72 | std::string filename("plot."); |
---|
73 | filename+=format; |
---|
74 | Graph graph(filename, format); |
---|
75 | graph.ymax(10); |
---|
76 | graph.current_color(255, 0, 0); |
---|
77 | SumVector data; |
---|
78 | data.set(99,1); |
---|
79 | graph.plot(data, "label", 1); |
---|
80 | } |
---|