Changeset 1360 for trunk/test/Suite.h


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

working on ticket #214

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.