Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / API_CppTest / INC / cpptest-compileroutput.h
1 // ---
2 //
3 // $Id: cpptest-compileroutput.h,v 1.3 2005/06/08 08:08:06 nilu Exp $
4 //
5 // CppTest - A C++ Unit Testing Framework
6 // Copyright (c) 2003 Niklas Lundell
7 //
8 // ---
9 //
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.
14 //
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.
19 //
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.
24 //
25 // ---
26
27 /** \file */
28
29 #ifndef CPPTEST_COMPILEROUTPUT_H
30 #define CPPTEST_COMPILEROUTPUT_H
31
32 #include <iostream>
33 #include <stdexcept>
34
35 #include "cpptest-output.h"
36
37 namespace Test
38 {
39 /// \brief Compiler-like output handler.
40 ///
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
43 /// failures.
44 ///
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.
51 ///
52 class CompilerOutput : public Output
53 {
54 public:
55 /// \brief Compiler output exception.
56 ///
57 /// Indicates that an invalid message format was given when creating
58 /// a compiler output. The failing format may be retrieved using the
59 /// what() method.
60 ///
61 class InvalidFormat : public std::logic_error
62 {
63 public:
64 InvalidFormat(const std::string& what)
65 : std::logic_error(what) {}
66 };
67
68 /// Pre-defined compiler output formats.
69 ///
70 enum Format
71 {
72 /// Generic compiler format, which equals:
73 /// <tt>%%file:%%line: %%text</tt>
74 ///
75 Generic,
76
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>.
80 ///
81 BCC,
82
83 /// <a href="http://gcc.gnu.org">GNU Compiler Collection</a>
84 /// (GCC) format, which equals:
85 /// <tt>%%file:%%line: %%text</tt>
86 ///
87 GCC,
88
89 /// <a href="http://www.microsoft.com">Microsoft Visual C++</a>
90 /// (MSVC) format, which equals:
91 /// <tt>%%file(%%line) : %%text</tt>
92 ///
93 MSVC
94 };
95
96 explicit CompilerOutput(Format format = Generic,
97 std::ostream& stream = std::cout);
98
99 explicit CompilerOutput(const std::string& format,
100 std::ostream& stream = std::cout);
101
102 virtual void assertment(const Source& s);
103
104 private:
105 std::string _format;
106 std::ostream& _stream;
107 };
108
109 } // namespace Test
110
111 #endif // #ifndef CPPTEST_COMPILEROUTPUT_H
112