Changeset 1360 for trunk/test/Suite.h
- Timestamp:
- Jun 26, 2008, 3:17:58 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/Suite.h
r1304 r1360 26 26 27 27 #include <fstream> 28 #include <sstream> 28 29 29 30 namespace theplu { … … 91 92 int return_value(void) const; 92 93 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 93 103 private: 94 104 bool verbose_; … … 118 128 } 119 129 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 120 153 }}} 121 154
Note: See TracChangeset
for help on using the changeset viewer.