Skip to content

Commit

Permalink
Added tests for all exception types derived from BaseExc.
Browse files Browse the repository at this point in the history
Signed-off-by: Cary Phillips <cary@ilm.com>
  • Loading branch information
cary-ilm committed Oct 7, 2019
1 parent a82c4c2 commit f82e198
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions IlmBase/IexTest/testBaseExc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include <testBaseExc.h>
#include <Iex.h>
#include <IexErrnoExc.h>
#include <iostream>
#include <stdexcept>
#include <assert.h>
Expand Down Expand Up @@ -214,6 +215,11 @@ test6()
IEX_INTERNAL_NAMESPACE::setStackTracer (getStackTrace);
assert (IEX_INTERNAL_NAMESPACE::stackTracer() == getStackTrace);

//
// Test the constructors that take char* and stringstream,
// and the += and assign functions.
//

T e1 ("arg");

e1 += "X";
Expand All @@ -222,7 +228,7 @@ test6()
e1 += s;

T e2 (e1);

assert (e1.message() == "argXY");
assert (e1.stackTrace() == getStackTrace());

Expand All @@ -233,6 +239,31 @@ test6()
assert (e2.message() == "Z");
e2.assign (s);
assert (e2.message() == "Y");

T e3 (s);
assert (e3.message() == s.str());

//
// Confirm the throw/catch
//

bool caught = false;

try
{
throw e1;
}
catch (T& e)
{
caught = true;
assert (e.message() == e1.message());
}
catch (...)
{
assert (false);
}

assert (caught);
}


Expand All @@ -259,17 +290,6 @@ testBaseExc()
test6<IEX_INTERNAL_NAMESPACE::NoImplExc>();
test6<IEX_INTERNAL_NAMESPACE::NullExc>();
test6<IEX_INTERNAL_NAMESPACE::TypeExc>();

#if XXX
test6<IEX_INTERNAL_NAMESPACE::ArgExc>();
test6<IEX_INTERNAL_NAMESPACE::LogicExc>();
test6<IEX_INTERNAL_NAMESPACE::InputExc>();
test6<IEX_INTERNAL_NAMESPACE::IoExc>();
test6<IEX_INTERNAL_NAMESPACE::MathExc>();
test6<IEX_INTERNAL_NAMESPACE::ErrnoExc>();
test6<IEX_INTERNAL_NAMESPACE::NoImplExc>();
test6<IEX_INTERNAL_NAMESPACE::NullExc>();
test6<IEX_INTERNAL_NAMESPACE::TypeExc>();
test6<IEX_INTERNAL_NAMESPACE::EpermExc>();
test6<IEX_INTERNAL_NAMESPACE::EnoentExc>();
test6<IEX_INTERNAL_NAMESPACE::EsrchExc>();
Expand Down Expand Up @@ -430,7 +450,6 @@ testBaseExc()
test6<IEX_INTERNAL_NAMESPACE::DivzeroExc>();
test6<IEX_INTERNAL_NAMESPACE::InexactExc>();
test6<IEX_INTERNAL_NAMESPACE::InvalidFpOpExc>();
#endif

std::cout << "ok\n" << std::endl;
}

0 comments on commit f82e198

Please sign in to comment.