1//
2// LogStreamTest.cpp
3//
4// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
5// All rights reserved.
6//
7// SPDX-License-Identifier: BSL-1.0
8//
9
10
11#include "LogStreamTest.h"
12#include "Poco/CppUnit/TestCaller.h"
13#include "Poco/CppUnit/TestSuite.h"
14#include "Poco/Logger.h"
15#include "Poco/LogStream.h"
16#include "Poco/AutoPtr.h"
17#include "TestChannel.h"
18
19
20using Poco::Logger;
21using Poco::LogStream;
22using Poco::Channel;
23using Poco::Message;
24using Poco::AutoPtr;
25
26
27LogStreamTest::LogStreamTest(const std::string& rName): CppUnit::TestCase(rName)
28{
29}
30
31
32LogStreamTest::~LogStreamTest()
33{
34}
35
36
37void LogStreamTest::testLogStream()
38{
39 AutoPtr<TestChannel> pChannel = new TestChannel;
40 Logger& root = Logger::root();
41 root.setChannel(pChannel);
42
43 LogStream ls(root);
44
45 ls << "information" << ' ' << 1 << std::endl;
46 assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_INFORMATION);
47 assertTrue (pChannel->list().begin()->getText() == "information 1");
48 pChannel->list().clear();
49
50 ls.error() << "error" << std::endl;
51 assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_ERROR);
52 assertTrue (pChannel->list().begin()->getText() == "error");
53 pChannel->list().clear();
54}
55
56
57void LogStreamTest::setUp()
58{
59}
60
61
62void LogStreamTest::tearDown()
63{
64}
65
66
67CppUnit::Test* LogStreamTest::suite()
68{
69 CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("LogStreamTest");
70
71 CppUnit_addTest(pSuite, LogStreamTest, testLogStream);
72
73 return pSuite;
74}
75