[test] memory access violation by calling <<-operator
Hi boost-users, I created a class and overload the <<-operator. Now I tried to test them by assigning an instance of the class to an ostringstream, but I get always the error: "fatal error in "EmptyVertex_output_stream": memory access violation occurred at address 0xcccccce0, while attempting to read inaccessible data" It's very curious, because assigning a string directly to the ostringstream, no error occurs. I'm using boost 1.35.0 and VS2003 The code: // test_class.cpp BOOST_AUTO_TEST_CASE( EmptyVertex_output_stream) { // 1 // const string vertexNameIn1 = "test name"; const EmptyVertex emptyVertex1(vertexNameIn1); ostringstream currString1; currString1 << emptyVertex1; // Error occurs here, see class_to_test.cpp string expString1 = "EmptyVertex(name=test name)"; BOOST_CHECK_EQUAL(currString1.str(), expString1); } //class_to_test.cpp /*public friend*/ ostream& operator<<(ostream& streamOut, const EmptyVertex& vertex) { streamOut << "EmptyVertex("; // Error occurs here streamOut << vertex.getName(); streamOut << ")"; return streamOut; } Can someone give me a clue? greetz, modbom -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
M. Siebeneicher
Hi boost-users,
I created a class and overload the <<-operator. Now I tried to test them by
assigning an instance of the class Why don;t you try to use output_test_stream instead. It's specifically designed for this purpose. Gennadiy
participants (2)
-
Gennaidy Rozental
-
M. Siebeneicher