#include <iostream>
#include <j/cppunit/cppunit.hpp>
#include <j/cppunit/assert.hpp>
#include <j/lang/exception.hpp>
#include <j/lang/errno.hpp>
using namespace j;
using namespace j::lang;
using namespace j::cppunit;
class ExceptionTest : public TestCase
{
public:
ExceptionTest() {}
~ExceptionTest() {}
void setUp() {}
void tearDown() {}
void testException()
{
Exception e;
String exp = j::lang::Errno::message(j::lang::Errno::get());
String act = e.getMessage();
assertEquals(exp, act);
}
void testExceptionMsg()
{
String msg = "ERROR MESSAGE";
Exception e(msg);
assertEquals(msg, e.getMessage());
}
void testExceptionCopy()
{
String msg = "ERROR MESSAGE 2";
Exception e(msg);
Exception ee = e;
assertEquals(msg, e.getMessage());
assertTrue(e != ee);
assertFalse(e == ee);
}
void testExceptionMove()
{
String msg = "ERROR MESSAGE 3";
Exception e(msg);
Exception ee = std::move(e);
assertEquals(msg, ee.getMessage());
}
void testExceptionToString()
{
String msg = "ERROR MESSAGE 3";
Exception e(msg);
assertEquals(msg, e.toString());
}
void suite()
{
RUN_TEST("new Exception()", testException);
RUN_TEST("new Exception(msg)", testExceptionMsg);
RUN_TEST("copy", testExceptionCopy);
RUN_TEST("move", testExceptionMove);
RUN_TEST("toString()", testExceptionToString);
}
};