Changeset 1360 for trunk


Ignore:
Timestamp:
Jun 26, 2008, 3:17:58 AM (13 years ago)
Author:
Peter
Message:

working on ticket #214

Location:
trunk/test
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Suite.h

    r1304 r1360  
    2626
    2727#include <fstream>
     28#include <sstream>
    2829
    2930namespace theplu {
     
    9192    int return_value(void) const;
    9293
     94    /**
     95       Function writes to a stream using operator<<, creates a new
     96       object using stream constructor, and the new object is written
     97       to another stream, and function check if the two outputs are
     98       equal.
     99    */
     100    template<class T>
     101    bool test_stream(const T&) const;
     102
    93103  private:
    94104    bool verbose_;
     
    118128  }
    119129
     130
     131  template<class T>
     132  bool Suite::test_stream(const T& t) const
     133  {
     134    this->err() << "Checking that output stream is valid as an input stream\n";
     135    std::stringstream ss;
     136    this->err() << "writing to output\n";
     137    ss << t;
     138    this->err() << "creating a new object from output\n";
     139    T t2(ss);
     140    std::stringstream ss2;
     141    this->err() << "writing to output\n";
     142    ss2 << t2;
     143    bool ok = ss2.str()==ss.str();
     144    if (!ok) {
     145      this->err() << "ERROR: first object gave following output:\n"
     146                  << ss.str() << "\n"
     147                  << "ERROR: and second object gave following output:\n"
     148                  << ss2.str() << "\n";
     149    }
     150    return ok;
     151  }
     152
    120153}}}
    121154
  • trunk/test/matrix_lookup_test.cc

    r1275 r1360  
    5454  else
    5555    suite.err() << "Ok" << std::endl;
     56
     57  // FIXME - see ticket:389
     58  //suite.add(suite.test_stream(m1));
    5659
    5760 
  • trunk/test/matrix_test.cc

    r1275 r1360  
    5757  for (size_t i=0; i<unit3x3.rows(); ++i)
    5858    unit3x3(i,i)=1;
     59
     60  suite.add(suite.test_stream(unit3x3));
    5961
    6062  suite.err() << "\tcopy constructor and operator!=" << std::endl;
  • trunk/test/vector_test.cc

    r1275 r1360  
    5858  for (size_t i=0; i<vec.size(); i++)
    5959    vec(i)=i;
     60
     61  suite.add(suite.test_stream(vec));
    6062
    6163  // checking that shuffle works
Note: See TracChangeset for help on using the changeset viewer.