Changeset 145


Ignore:
Timestamp:
Aug 9, 2006, 11:36:31 PM (13 years ago)
Author:
Jari Häkkinen
Message:

Removed test/parser.cc and test/stats.cc. These tests are an essential
part in the test/directory.cc and test/file.cc, and thus redundant.
Fixed the other tests to actually report success or failure.

Location:
trunk
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Gnuplot.cc

    r124 r145  
    7777
    7878 
    79   void Gnuplot::command(const std::string& cmdstr)
     79  int Gnuplot::command(const std::string& cmdstr)
    8080  {
    81     fputs(cmdstr.c_str(),pipe_);
    82     if (*(cmdstr.rbegin())!='\n')
    83       fputc('\n',pipe_);
    84     fflush(pipe_);
     81    if (fputs(cmdstr.c_str(),pipe_)==EOF)
     82      return EOF;
     83    if ((*(cmdstr.rbegin())!='\n') && (fputc('\n',pipe_)==EOF))
     84      return EOF;
     85    return fflush(pipe_);
    8586  }
    8687
  • trunk/lib/Gnuplot.h

    r132 r145  
    7272
    7373    ///
    74     /// Send arbitrary commands to Gnuplot.
     74    /// @brief Send arbitrary commands to Gnuplot.
    7575    ///
    76     /// @return 0 if fputs, fputc, and fflush are succesful
     76    /// @return 0 on success (underlying fputs, fputc, and fflush are
     77    /// succesful), EOF otherwise.
    7778    ///
    78     void command(const std::string&);
     79    int command(const std::string&);
    7980
    8081    ///
     
    99100    /// Gnuplot usage.
    100101    ///
     102    /// @return 0 on success, EOF otherwise.
     103    ///
    101104    template <class T1, class T2>
    102     void plot(const std::vector<T1>& y, const std::vector<T2>& x)
    103     { plot(y,x,"plot"); }
     105    int plot(const std::vector<T1>& y, const std::vector<T2>& x)
     106    { return plot(y,x,"plot"); }
    104107
    105108    template <class T1>
    106     void plot(const std::vector<T1>& y,
    107               const std::vector<T1>& x=std::vector<T1>())
    108     { plot(y,x,"plot"); }
     109    int plot(const std::vector<T1>& y,const std::vector<T1>& x=std::vector<T1>())
     110    { return plot(y,x,"plot"); }
    109111
    110112    ///
     
    113115    /// Gnuplot usage.
    114116    ///
     117    /// @return 0 on success, EOF otherwise.
     118    ///
    115119    template <class T1, class T2>
    116     void replot(const std::vector<T1>& y, const std::vector<T2>& x)
    117     { plot(y,x,"replot"); }
     120    int replot(const std::vector<T1>& y, const std::vector<T2>& x)
     121    { return plot(y,x,"replot"); }
    118122
    119123    template <class T1>
    120     void replot(const std::vector<T1>& y,
     124    int replot(const std::vector<T1>& y,
    121125              const std::vector<T1>& x=std::vector<T1>())
    122     { plot(y,x,"replot"); }
     126    { return plot(y,x,"replot"); }
    123127
    124128  private:
     
    134138    ///
    135139    template <class T1, class T2>
    136     void plot(const std::vector<T1>& y, const std::vector<T2>& x,
    137               const std::string& plotcmd)
     140    int plot(const std::vector<T1>& y, const std::vector<T2>& x,
     141             const std::string& plotcmd)
    138142    {
    139143      assert(x.size()==y.size() || x.empty());
     
    152156      cmdstring << "e\n";
    153157
    154       command(cmdstring.str());
     158      return command(cmdstring.str());
    155159    }
    156160
  • trunk/test/Makefile.am

    r144 r145  
    2222# 02111-1307, USA.
    2323
    24 TESTS = directory file gnuplot_pipe stats parser
     24TESTS = directory file gnuplot_pipe
    2525
    2626check_PROGRAMS = $(TESTS)
     
    3535file_SOURCES = file.cc
    3636gnuplot_pipe_SOURCES = gnuplot_pipe.cc
    37 parser_SOURCES = parser.cc
    38 stats_SOURCES = stats.cc
    3937
    4038clean-local:
  • trunk/test/directory.cc

    r144 r145  
    2424#include "Directory.h"
    2525
    26 #include <string>
     26#include <iostream>
    2727
    2828int main(const int argc,const char* argv[])
    2929{
    30   using namespace theplu::svnstat;
    31   std::string path("..");
    32   Directory directory(0,path);
     30  try {
     31    // create a file structure of a subversion WC
     32    theplu::svnstat::Directory directory(0,"..");
     33    directory.parse();
     34  }
     35  catch (const std::runtime_error& x) {
     36    std::cerr << "Test directory: " << x.what() << std::endl;
     37    return -1;
     38  }
    3339  return 0;
    3440}
  • trunk/test/file.cc

    r144 r145  
    2323
    2424#include "File.h"
    25 #include "Directory.h"
    2625
    27 #include <string>
     26#include <iostream>
    2827
    2928int main(const int argc,const char* argv[])
    3029{
    31   using namespace theplu::svnstat;
    32   std::string path("file.cc");
    33   File file(0,path);
    34   file.parse();
     30  try {
     31    theplu::svnstat::File file(0,"file.cc");
     32    file.parse();
     33  }
     34  catch (const std::runtime_error& x) {
     35    std::cerr << "Test file: " << x.what() << std::endl;
     36    return -1;
     37  }
    3538  return 0;
    3639}
  • trunk/test/gnuplot_pipe.cc

    r119 r145  
    3030  using namespace theplu;
    3131
    32   bool ok = true;
     32  bool ok = false; // false indicates success, i.e., no errors detected.
    3333
    3434  std::vector<double> x,y;
     
    3939
    4040  svnstat::Gnuplot gnuplot1;
    41   gnuplot1.command("set output 'test1.png'; set term png ; set title 'sine'");
    42   gnuplot1.command("plot sin(x) title 'sine of x' with lines");
     41  ok|=gnuplot1.command("set output 'test1.png'; set term png ; set title 'sine'");
     42  ok|=gnuplot1.command("plot sin(x) title 'sine of x' with lines");
    4343
    4444  svnstat::Gnuplot gnuplot2;
    45   gnuplot2.command("set output 'test2.png'; set term png");
    46   gnuplot2.plot(x);
     45  ok|=gnuplot2.command("set output 'test2.png'; set term png");
     46  ok|=gnuplot2.plot(x);
    4747
    4848  svnstat::Gnuplot gnuplot3;
    49   gnuplot3.command("set output 'test3.png'; set term png");
     49  ok|=gnuplot3.command("set output 'test3.png'; set term png");
    5050  gnuplot3.linetitle("parabola");
    51   gnuplot3.plot(x,y);
    52   gnuplot3.command("set output 'test4.png'");
    53   gnuplot3.command("set title 'ddddd'");
     51  ok|=gnuplot3.plot(x,y);
     52  ok|=gnuplot3.command("set output 'test4.png'");
     53  ok|=gnuplot3.command("set title 'ddddd'");
    5454  //gnuplot3.linestyle("linespoints");
    5555  gnuplot3.linetitle("bajs");
    56   gnuplot3.plot(x);
     56  ok|=gnuplot3.plot(x);
    5757
    5858  /*
     
    6767  */
    6868
    69   return (ok ? 0 : -1);
     69  return ok;
    7070}
Note: See TracChangeset for help on using the changeset viewer.