1 | // $Id: graph.cc 1184 2010-08-25 01:14:47Z 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 | |
---|
26 | #include <cstdlib> |
---|
27 | #include <ostream> |
---|
28 | |
---|
29 | using namespace theplu::svndigest; |
---|
30 | |
---|
31 | void test_graph(const std::string format, test::Suite& suite); |
---|
32 | void test_graph__(const std::string format, test::Suite& suite); |
---|
33 | |
---|
34 | int main(int argc, char* argv[]) |
---|
35 | { |
---|
36 | test::Suite suite(argc, argv); |
---|
37 | |
---|
38 | #ifndef HAVE_PLPLOT |
---|
39 | suite.out() << "no plplot: skip test\n"; |
---|
40 | exit(EXIT_SKIP); |
---|
41 | #endif |
---|
42 | |
---|
43 | test_graph("svg", suite); |
---|
44 | // Need to create an instance of Graph (plstream) since there is a |
---|
45 | // bug in plplot with dynamic loading of runtime libraries. The |
---|
46 | // issue is reported in the plplot issue tracking system |
---|
47 | // https://sf.net/tracker/?func=detail&aid=3009045&group_id=2915&atid=102915 |
---|
48 | // and as http://dev.thep.lu.se/svndigest/ticket/472. Simply remove |
---|
49 | // this comment and the next line of code when plplot developers |
---|
50 | // fixes their bug. |
---|
51 | // |
---|
52 | // Omitting the dummy instance will cause segmentation fault. |
---|
53 | Graph dummy_never_used("/dev/null", "png"); |
---|
54 | test_graph("png", suite); |
---|
55 | test_graph("pdf", suite); |
---|
56 | |
---|
57 | // FIXME: in 0.9pre replace with |
---|
58 | // return suite.exit_statu(); |
---|
59 | if (suite.ok()) |
---|
60 | return EXIT_SUCCESS; |
---|
61 | return EXIT_FAILURE; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | void test_graph(const std::string format, test::Suite& suite) |
---|
66 | { |
---|
67 | suite.out() << "testing " << format << std::endl; |
---|
68 | for (size_t i=0; i<20; ++i) |
---|
69 | test_graph__(format, suite); |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | void test_graph__(const std::string format, test::Suite& suite) |
---|
74 | { |
---|
75 | std::string filename("plot."); |
---|
76 | filename+=format; |
---|
77 | Graph graph(filename, format); |
---|
78 | graph.ymax(10); |
---|
79 | graph.current_color(255, 0, 0); |
---|
80 | std::vector<unsigned int> data(100,1); |
---|
81 | graph.plot(data, "label", 1); |
---|
82 | } |
---|