Changeset ef9dff6 for src/Helpers/unittests
- Timestamp:
- Jul 14, 2014, 8:37:03 PM (11 years ago)
- Children:
- 0ab195
- Parents:
- ca940b
- git-author:
- Frederik Heber <heber@…> (06/19/14 16:26:39)
- git-committer:
- Frederik Heber <heber@…> (07/14/14 20:37:03)
- Location:
- src/Helpers/unittests
- Files:
-
- 4 edited
-
LogUnitTest.cpp (modified) (3 diffs)
-
LogUnitTest.hpp (modified) (2 diffs)
-
Makefile.am (modified) (1 diff)
-
stubs/loggerStub.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Helpers/unittests/LogUnitTest.cpp
rca940b ref9dff6 39 39 void LogTest::setUp() 40 40 { 41 } ;41 } 42 42 43 43 void LogTest::tearDown() … … 45 45 logger::purgeInstance(); 46 46 errorLogger::purgeInstance(); 47 } ;47 } 48 48 49 49 /** … … 70 70 CPPUNIT_ASSERT(!DoLog(4)); 71 71 CPPUNIT_ASSERT(!DoeLog(4)); 72 }; 72 } 73 74 /** 75 * UnitTest for log() 76 */ 77 void LogTest::newOutputTest() 78 { 79 // check whether redirecting output works 80 std::stringstream teststream; 81 { 82 Log().setOutputStream(&teststream); 83 logger::getInstance().setVerbosity(2); 84 Log() << Verbose(0) << std::string("test"); 85 // DoLog(0) && (Log() << Verbose(0) << "test" << endl); 86 CPPUNIT_ASSERT_EQUAL( std::string("test"), teststream.str() ); 87 Log().setOutputStream(NULL); // go to default, as stringstream is destroyed 88 } 89 // redirect to NULL changes to cout 90 teststream.str(""); 91 { 92 DoLog(0) && (Log() << Verbose(0) << "test" << endl); 93 CPPUNIT_ASSERT_EQUAL( std::string(""), teststream.str() ); 94 } 95 } -
src/Helpers/unittests/LogUnitTest.hpp
rca940b ref9dff6 20 20 CPPUNIT_TEST_SUITE( LogTest) ; 21 21 CPPUNIT_TEST ( logTest ); 22 CPPUNIT_TEST ( newOutputTest ); 22 23 CPPUNIT_TEST_SUITE_END(); 23 24 … … 25 26 void setUp(); 26 27 void tearDown(); 28 void newOutputTest(); 27 29 28 30 void logTest(); -
src/Helpers/unittests/Makefile.am
rca940b ref9dff6 77 77 LogUnitTest_SOURCES = UnitTestMain.cpp \ 78 78 ../Helpers/unittests/LogUnitTest.cpp \ 79 ../Helpers/unittests/LogUnitTest.hpp \ 80 ../Helpers/unittests/stubs/errorloggerStub.cpp \ 81 ../Helpers/unittests/stubs/loggerStub.cpp 79 ../Helpers/unittests/LogUnitTest.hpp 82 80 nodist_LogUnitTest_SOURCES = \ 83 81 $(top_srcdir)/src/CodePatterns/Assert.hpp \ -
src/Helpers/unittests/stubs/loggerStub.cpp
rca940b ref9dff6 26 26 int logger::verbosity = 2; 27 27 ostream* logger::nix = NULL; 28 ostream* logger::defaultout = NULL; 29 ostream* logger::out = NULL; 28 30 29 31 /** … … 35 37 { 36 38 nix = new stringstream; 39 defaultout = new stringstream; 40 out = defaultout; 37 41 }; 38 42 … … 43 47 { 44 48 delete nix; 49 delete defaultout; 50 out = NULL; 45 51 } 46 52 … … 65 71 } 66 72 73 /** Sets a new output stream. 74 * 75 * \param _newout new output stream, if NULL we set to defaultout 76 */ 77 void logger::setOutputStream(ostream *_newout) 78 { 79 if(_newout != NULL) 80 out = _newout; 81 else 82 out = defaultout; 83 } 84 67 85 /** 68 86 * Operator for the Binary(arg) call.
Note:
See TracChangeset
for help on using the changeset viewer.
