diff --git a/beast/module/core/text/LexicalCast.h b/beast/module/core/text/LexicalCast.h index ebaf52275a..8e1f4a471c 100644 --- a/beast/module/core/text/LexicalCast.h +++ b/beast/module/core/text/LexicalCast.h @@ -20,12 +20,13 @@ #ifndef BEAST_LEXICALCAST_H_INCLUDED #define BEAST_LEXICALCAST_H_INCLUDED -#include +#include #include // #include #include #include +#include #include namespace beast { diff --git a/beast/module/core/thread/DeadlineTimer.h b/beast/module/core/thread/DeadlineTimer.h index 0d8923868c..0cc96f208d 100644 --- a/beast/module/core/thread/DeadlineTimer.h +++ b/beast/module/core/thread/DeadlineTimer.h @@ -20,8 +20,9 @@ #ifndef BEAST_DEADLINETIMER_H_INCLUDED #define BEAST_DEADLINETIMER_H_INCLUDED -namespace beast -{ +#include + +namespace beast { /** Provides periodic or one time notifications at a specified time interval. */ diff --git a/beast/utility/Utility.unity.cpp b/beast/utility/Utility.unity.cpp index 0b6cbe7962..a0e29bcd79 100644 --- a/beast/utility/Utility.unity.cpp +++ b/beast/utility/Utility.unity.cpp @@ -31,5 +31,6 @@ #include #include -#include +#include #include +#include diff --git a/beast/utility/impl/Journal.cpp b/beast/utility/impl/Journal.cpp index 3a5c030f53..25ee34609a 100644 --- a/beast/utility/impl/Journal.cpp +++ b/beast/utility/impl/Journal.cpp @@ -67,7 +67,7 @@ Journal::Sink& Journal::getNullSink () //------------------------------------------------------------------------------ Journal::Sink::Sink () - : m_level (kAll) + : m_level (kWarning) , m_console (false) { } diff --git a/beast/utility/tests/Journal.test.cpp b/beast/utility/tests/Journal.test.cpp new file mode 100644 index 0000000000..b08f48b102 --- /dev/null +++ b/beast/utility/tests/Journal.test.cpp @@ -0,0 +1,100 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#include +#include + +namespace beast { + +class Journal_test : public unit_test::suite +{ +public: + class TestSink : public Journal::Sink + { + private: + int m_count; + + public: + TestSink() + : m_count(0) + { + } + + int + count() const + { + return m_count; + } + + void + reset() + { + m_count = 0; + } + + void + write (Journal::Severity, std::string const&) + { + ++m_count; + } + }; + + void run () + { + TestSink sink; + + sink.severity(Journal::kInfo); + + Journal j(sink); + + j.trace << " "; + expect(sink.count() == 0); + j.debug << " "; + expect(sink.count() == 0); + j.info << " "; + expect(sink.count() == 1); + j.warning << " "; + expect(sink.count() == 2); + j.error << " "; + expect(sink.count() == 3); + j.fatal << " "; + expect(sink.count() == 4); + + sink.reset(); + + sink.severity(Journal::kDebug); + + j.trace << " "; + expect(sink.count() == 0); + j.debug << " "; + expect(sink.count() == 1); + j.info << " "; + expect(sink.count() == 2); + j.warning << " "; + expect(sink.count() == 3); + j.error << " "; + expect(sink.count() == 4); + j.fatal << " "; + expect(sink.count() == 5); + } +}; + +BEAST_DEFINE_TESTSUITE_MANUAL(Journal,utility,beast); + +} // beast