| 1 | // |
|---|---|
| 2 | // NullStreamTest.cpp |
| 3 | // |
| 4 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
| 5 | // and Contributors. |
| 6 | // |
| 7 | // SPDX-License-Identifier: BSL-1.0 |
| 8 | // |
| 9 | |
| 10 | |
| 11 | #include "NullStreamTest.h" |
| 12 | #include "Poco/CppUnit/TestCaller.h" |
| 13 | #include "Poco/CppUnit/TestSuite.h" |
| 14 | #include "Poco/NullStream.h" |
| 15 | |
| 16 | |
| 17 | using Poco::NullInputStream; |
| 18 | using Poco::NullOutputStream; |
| 19 | |
| 20 | |
| 21 | NullStreamTest::NullStreamTest(const std::string& rName): CppUnit::TestCase(rName) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | |
| 26 | NullStreamTest::~NullStreamTest() |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | |
| 31 | void NullStreamTest::testInput() |
| 32 | { |
| 33 | NullInputStream istr; |
| 34 | assertTrue (istr.good()); |
| 35 | assertTrue (!istr.eof()); |
| 36 | int c = istr.get(); |
| 37 | assertTrue (c == -1); |
| 38 | assertTrue (istr.eof()); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | void NullStreamTest::testOutput() |
| 43 | { |
| 44 | NullOutputStream ostr; |
| 45 | assertTrue (ostr.good()); |
| 46 | ostr << "Hello, world!"; |
| 47 | assertTrue (ostr.good()); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | void NullStreamTest::setUp() |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | |
| 56 | void NullStreamTest::tearDown() |
| 57 | { |
| 58 | } |
| 59 | |
| 60 | |
| 61 | CppUnit::Test* NullStreamTest::suite() |
| 62 | { |
| 63 | CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NullStreamTest"); |
| 64 | |
| 65 | CppUnit_addTest(pSuite, NullStreamTest, testInput); |
| 66 | CppUnit_addTest(pSuite, NullStreamTest, testOutput); |
| 67 | |
| 68 | return pSuite; |
| 69 | } |
| 70 |