00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://svn.east.isi.edu/torc/trunk/src/torc/common/NullOutputStreamUnitTest.cpp $ 00003 // $Id: NullOutputStreamUnitTest.cpp 479 2011-06-05 04:04:54Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Unit test for NullOutputStream class. 00018 00019 #include <boost/test/unit_test.hpp> 00020 #include "torc/common/NullOutputStream.hpp" 00021 00022 namespace torc { 00023 namespace common { 00024 00025 BOOST_AUTO_TEST_SUITE(common) 00026 00027 /// \brief Unit test for the NullOutputStream class. 00028 BOOST_AUTO_TEST_CASE(NullOutputStreamUnitTest) { 00029 // enable all exceptions on the global null output stream, and try writing a bunch of stuff 00030 bool passed = true; 00031 try { 00032 cnull.exceptions(std::ios_base::eofbit | std::ios_base::failbit | std::ios_base::badbit); 00033 for(int i = 0; i < 1000000; i++) cnull << i; 00034 } 00035 catch(...) { 00036 passed = false; 00037 } 00038 BOOST_CHECK(passed); 00039 } 00040 00041 BOOST_AUTO_TEST_SUITE_END() 00042 00043 } // namespace common 00044 } // namespace torc