summaryrefslogtreecommitdiff
path: root/cppunit/source/cppunit/Asserter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cppunit/source/cppunit/Asserter.cpp')
-rw-r--r--cppunit/source/cppunit/Asserter.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/cppunit/source/cppunit/Asserter.cpp b/cppunit/source/cppunit/Asserter.cpp
new file mode 100644
index 000000000000..904ed7800b8a
--- /dev/null
+++ b/cppunit/source/cppunit/Asserter.cpp
@@ -0,0 +1,81 @@
+#include <cppunit/Asserter.h>
+#include <cppunit/NotEqualException.h>
+#include <cppunit/stringhelper.hxx>
+
+namespace CppUnit
+{
+
+
+namespace Asserter
+{
+
+void
+fail( std::string const& message,
+ SourceLine const& sourceLine )
+{
+ throw Exception( message, sourceLine );
+}
+
+void
+failStub( std::string const& message,
+ SourceLine const& sourceLine )
+{
+ throw StubException( message, sourceLine );
+}
+
+
+void
+failIf( bool shouldFail,
+ std::string const& message,
+ SourceLine const& location )
+{
+ if ( shouldFail )
+ {
+ fail( message, location );
+ }
+}
+
+// -----------------------------------------------------------------------------
+void
+failIf( bool shouldFail,
+ rtl::OUString const& _suMessage,
+ SourceLine const& location )
+{
+ if ( shouldFail )
+ {
+ rtl::OString sMessage;
+ sMessage <<= _suMessage;
+ std::string message;
+ message = sMessage.getStr();
+ fail( message, location );
+ }
+}
+// -----------------------------------------------------------------------------
+
+void
+failNotEqual( std::string const& expected,
+ std::string const& actual,
+ SourceLine const& sourceLine,
+ std::string const& additionalMessage )
+{
+ throw NotEqualException( expected,
+ actual,
+ sourceLine,
+ additionalMessage );
+}
+
+
+void
+failNotEqualIf( bool shouldFail,
+ std::string const& expected,
+ std::string const& actual,
+ SourceLine const& sourceLine,
+ std::string const& additionalMessage )
+{
+ if ( shouldFail )
+ failNotEqual( expected, actual, sourceLine, additionalMessage );
+}
+
+
+} // namespace Asserter
+} // namespace CppUnit