mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-26 16:19:30 +03:00
r5 | charles.nicholson | 2010-03-15 17:46:01 -0500 (Mon, 15 Mar 2010) | 1 line
remove leftover exception test structures, fix ReportAssert for no-exceptions build
This commit is contained in:
parent
4f556d6539
commit
23c7368d92
5 changed files with 33 additions and 38 deletions
|
|
@ -1,4 +1,7 @@
|
|||
#include "AssertException.h"
|
||||
|
||||
#ifdef UNITTEST_USE_EXCEPTIONS
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace UnitTest {
|
||||
|
|
@ -12,11 +15,11 @@ AssertException::AssertException(char const* description, char const* filename,
|
|||
strcpy(m_filename, filename);
|
||||
}
|
||||
|
||||
AssertException::~AssertException() throw()
|
||||
AssertException::~AssertException()
|
||||
{
|
||||
}
|
||||
|
||||
char const* AssertException::what() const throw()
|
||||
char const* AssertException::what() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
|
@ -32,3 +35,5 @@ int AssertException::LineNumber() const
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
#ifndef UNITTEST_ASSERTEXCEPTION_H
|
||||
#define UNITTEST_ASSERTEXCEPTION_H
|
||||
|
||||
#include <exception>
|
||||
#include "Config.h"
|
||||
|
||||
#ifdef UNITTEST_USE_EXCEPTIONS
|
||||
|
||||
#include <exception>
|
||||
|
||||
namespace UnitTest {
|
||||
|
||||
|
|
@ -10,9 +13,9 @@ class AssertException : public std::exception
|
|||
{
|
||||
public:
|
||||
AssertException(char const* description, char const* filename, int lineNumber);
|
||||
virtual ~AssertException() throw();
|
||||
virtual ~AssertException();
|
||||
|
||||
virtual char const* what() const throw();
|
||||
virtual char const* what() const;
|
||||
|
||||
char const* Filename() const;
|
||||
int LineNumber() const;
|
||||
|
|
@ -26,3 +29,5 @@ private:
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@
|
|||
// uncomment this line to use the custom MemoryOutStream (no deps on std::ostringstream).
|
||||
|
||||
#define UNITTEST_USE_CUSTOM_STREAMS
|
||||
#define UNITTEST_USE_EXCEPTIONS
|
||||
//#define UNITTEST_USE_EXCEPTIONS
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
#include "ReportAssert.h"
|
||||
#include "AssertException.h"
|
||||
|
||||
namespace UnitTest {
|
||||
|
||||
void ReportAssert(char const* description, char const* filename, int lineNumber)
|
||||
{
|
||||
throw AssertException(description, filename, lineNumber);
|
||||
}
|
||||
|
||||
}
|
||||
#include "ReportAssert.h"
|
||||
#include "AssertException.h"
|
||||
|
||||
namespace UnitTest {
|
||||
|
||||
void ReportAssert(char const* description, char const* filename, int lineNumber)
|
||||
{
|
||||
(void)description;
|
||||
(void)filename;
|
||||
(void)lineNumber;
|
||||
|
||||
#ifdef UNITTEST_USE_EXCEPTIONS
|
||||
throw AssertException(description, filename, lineNumber);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,17 +206,6 @@ TEST(CheckCloseDoesNotHaveSideEffectsWhenFailing)
|
|||
CHECK_EQUAL(1, g_sideEffect);
|
||||
}
|
||||
|
||||
|
||||
class ThrowingObject
|
||||
{
|
||||
public:
|
||||
float operator[](int) const
|
||||
{
|
||||
throw "Test throw";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST(CheckArrayCloseSucceedsOnEqual)
|
||||
{
|
||||
bool failure = true;
|
||||
|
|
@ -404,16 +393,6 @@ TEST(CheckArrayCloseDoesNotHaveSideEffectsWhenFailing)
|
|||
CHECK_EQUAL(1, g_sideEffect);
|
||||
}
|
||||
|
||||
class ThrowingObject2D
|
||||
{
|
||||
public:
|
||||
float* operator[](int) const
|
||||
{
|
||||
throw "Test throw";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST(CheckArray2DCloseSucceedsOnEqual)
|
||||
{
|
||||
bool failure = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue