3 // $Id: cpptest-compileroutput.h,v 1.3 2005/06/08 08:08:06 nilu Exp $
5 // CppTest - A C++ Unit Testing Framework
6 // Copyright (c) 2003 Niklas Lundell
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the
22 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 // Boston, MA 02111-1307, USA.
29 #ifndef CPPTEST_COMPILEROUTPUT_H
30 #define CPPTEST_COMPILEROUTPUT_H
35 #include "cpptest-output.h"
39 /// \brief Compiler-like output handler.
41 /// %Test suite output handler that only outputs failures in compiler
42 /// warning/error format. This way, you can use your IDE to browse between
45 /// The output format is configurable to be able to emulate different
46 /// compiler outputs. The following modifiers exist:
47 /// - \e %file Outputs the file containing the test function.
48 /// - \e %line Line number for the the test function.
49 /// - \e %text Expression (or message) that caused the assertment.
50 /// Note that each modifier can only be specified once.
52 class CompilerOutput
: public Output
55 /// \brief Compiler output exception.
57 /// Indicates that an invalid message format was given when creating
58 /// a compiler output. The failing format may be retrieved using the
61 class InvalidFormat
: public std::logic_error
64 InvalidFormat(const std::string
& what
)
65 : std::logic_error(what
) {}
68 /// Pre-defined compiler output formats.
72 /// Generic compiler format, which equals:
73 /// <tt>%%file:%%line: %%text</tt>
77 /// <a href="http://www.borland.com/products/downloads/download_cbuilder.html">
78 /// Borland C++ Compiler</a> (BCC) format, which equals:
79 /// <tt>Error cpptest %%file %%line: %%text</tt>.
83 /// <a href="http://gcc.gnu.org">GNU Compiler Collection</a>
84 /// (GCC) format, which equals:
85 /// <tt>%%file:%%line: %%text</tt>
89 /// <a href="http://www.microsoft.com">Microsoft Visual C++</a>
90 /// (MSVC) format, which equals:
91 /// <tt>%%file(%%line) : %%text</tt>
96 explicit CompilerOutput(Format format
= Generic
,
97 std::ostream
& stream
= std::cout
);
99 explicit CompilerOutput(const std::string
& format
,
100 std::ostream
& stream
= std::cout
);
102 virtual void assertment(const Source
& s
);
106 std::ostream
& _stream
;
111 #endif // #ifndef CPPTEST_COMPILEROUTPUT_H