1 | #ifndef CPPUNIT_SOURCELINE_H |
---|
2 | #define CPPUNIT_SOURCELINE_H |
---|
3 | |
---|
4 | #include <cppunit/Portability.h> |
---|
5 | #include <string> |
---|
6 | |
---|
7 | /*! \brief Constructs a SourceLine object initialized with the location where the macro is expanded. |
---|
8 | * \ingroup CreatingNewAssertions |
---|
9 | * \relates CppUnit::SourceLine |
---|
10 | * Used to write your own assertion macros. |
---|
11 | * \see Asserter for example of usage. |
---|
12 | */ |
---|
13 | #define CPPUNIT_SOURCELINE() CPPUNIT_NS::SourceLine( __FILE__, __LINE__ ) |
---|
14 | |
---|
15 | |
---|
16 | CPPUNIT_NS_BEGIN |
---|
17 | |
---|
18 | |
---|
19 | /*! \brief Represents a source line location. |
---|
20 | * \ingroup CreatingNewAssertions |
---|
21 | * \ingroup BrowsingCollectedTestResult |
---|
22 | * |
---|
23 | * Used to capture the failure location in assertion. |
---|
24 | * |
---|
25 | * Use the CPPUNIT_SOURCELINE() macro to construct that object. Typically used when |
---|
26 | * writing an assertion macro in association with Asserter. |
---|
27 | * |
---|
28 | * \see Asserter. |
---|
29 | */ |
---|
30 | class CPPUNIT_API SourceLine |
---|
31 | { |
---|
32 | public: |
---|
33 | SourceLine(); |
---|
34 | |
---|
35 | // Ensure thread-safe copy by detaching the string buffer. |
---|
36 | SourceLine( const SourceLine &other ); |
---|
37 | |
---|
38 | SourceLine( const std::string &fileName, |
---|
39 | int lineNumber ); |
---|
40 | |
---|
41 | SourceLine &operator =( const SourceLine &other ); |
---|
42 | |
---|
43 | /// Destructor. |
---|
44 | virtual ~SourceLine(); |
---|
45 | |
---|
46 | bool isValid() const; |
---|
47 | |
---|
48 | int lineNumber() const; |
---|
49 | |
---|
50 | std::string fileName() const; |
---|
51 | |
---|
52 | bool operator ==( const SourceLine &other ) const; |
---|
53 | bool operator !=( const SourceLine &other ) const; |
---|
54 | |
---|
55 | private: |
---|
56 | std::string m_fileName; |
---|
57 | int m_lineNumber; |
---|
58 | }; |
---|
59 | |
---|
60 | |
---|
61 | CPPUNIT_NS_END |
---|
62 | |
---|
63 | #endif // CPPUNIT_SOURCELINE_H |
---|