source: trunk/test/gnuplot_pipe.cc @ 107

Last change on this file since 107 was 107, checked in by Peter Johansson, 15 years ago

Gnuplot functions returning int and utilizing that in the test. However the warning sent from Gnuplot ref #37 is not caught since there is no problem with the pipe there.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1// $Id: gnuplot_pipe.cc 107 2006-06-28 09:12:38Z peter $
2
3/*
4  Copyright (C) 2006 Jari Häkkinen
5
6  This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat
7
8  svnstat 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 2 of the License, or
11  (at your option) any later version.
12
13  svnstat 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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "Gnuplot.h"
25
26#include <iostream>
27#include <vector>
28
29int main(const int argc,const char* argv[])
30{ 
31  using namespace theplu;
32
33  bool ok = true;
34
35  std::vector<double> x,y;
36  for (int i=-10; i<=10; ++i) {
37    x.push_back(i);
38    y.push_back(i*i);
39  }
40
41  svnstat::Gnuplot gnuplot1;
42  //if (gnuplot1.command("set output 'test1.png'; set term png ; set title 'sine'"))
43  //ok = false;
44    //if (gnuplot1.command("plot sin(x) title 'sine of x' with lines"))
45    //ok = false;
46
47  svnstat::Gnuplot gnuplot2;
48  //if (gnuplot2.command("set output 'test2.png'; set term png"))
49  //gnuplot2.plot(x);
50
51  svnstat::Gnuplot gnuplot3;
52  if (gnuplot3.command("set output 'test3.png'; set term png"))
53    ok=false;
54  gnuplot3.linetitle("parabola");
55  if (gnuplot3.plot(x,y))
56    ok=false;
57  if (gnuplot3.command("set output 'test4.png'; set title 'composite'"))
58    ok=false;
59  gnuplot3.linestyle("linespoints");
60  gnuplot3.linetitle("");
61  if (gnuplot3.replot(x))
62    ok=false;
63
64  /*
65  // Jari, if we want to avoid the above usage of plot_x and plot_xy,
66  // we need to do something like this. Of course 'filename.data'
67  // needs to be created by the user (this is hidden for the user in
68  // plot_x and plot_xy). Note, the below example compiles, but will
69  // fail at run time if 'filename.data' does not, miraculously, exist.
70  svnstat::Gnuplot gnuplot4;
71  gnuplot4.command("set output 'test5.png'\nset term png");
72  gnuplot4.command("plot 'filename.data' using 1:2 with linespoints");
73  */
74
75  return (ok ? 0 : -1);
76}
Note: See TracBrowser for help on using the repository browser.