74 int testErrorSeverity();
100 total += throwType<gnsstk::Exception>();
101 total += throwType<gnsstk::InvalidParameter>();
102 total += throwType<gnsstk::InvalidRequest>();
103 total += throwType<gnsstk::AssertionFailure>();
104 total += throwType<gnsstk::AccessError>();
105 total += throwType<gnsstk::IndexOutOfBoundsException>();
106 total += throwType<gnsstk::InvalidArgumentException>();
107 total += throwType<gnsstk::ConfigurationException>();
108 total += throwType<gnsstk::FileMissingException>();
109 total += throwType<gnsstk::SystemSemaphoreException>();
110 total += throwType<gnsstk::SystemPipeException>();
111 total += throwType<gnsstk::SystemQueueException>();
112 total += throwType<gnsstk::OutOfMemory>();
113 total += throwType<gnsstk::ObjectNotFound>();
114 total += throwType<gnsstk::NullPointerException>();
115 total += throwType<gnsstk::UnimplementedException>();
123 TUDEF(
"Exception",
"getErrorId()");
124 unsigned loc1Line = 0, loc2Line = 0;
126 std::string
fn(
"testErrorSeverity");
132 testFramework.changeSourceMethod(
"GNSSTK_THROW");
133 TUFAIL(
"Did not throw an exception when expected");
137 testFramework.changeSourceMethod(
"GNSSTK_THROW");
139 testFramework.changeSourceMethod(
"getErrorId");
141 testFramework.changeSourceMethod(
"isRecoverable");
142 testFramework.assert(exc.
isRecoverable(),
"Incorrect severity", __LINE__);
143 testFramework.changeSourceMethod(
"getLocationCount");
145 testFramework.changeSourceMethod(
"getTextCount");
147 testFramework.changeSourceMethod(
"addText");
150 testFramework.changeSourceMethod(
"addLocation");
161 testFramework.changeSourceMethod(
"getLineNumber");
164 testFramework.changeSourceMethod(
"getFileName");
167 testFramework.changeSourceMethod(
"getFunctionName");
168 #if defined ( __FUNCTION__ )
178 testFramework.changeSourceMethod(
"GNSSTK_THROW");
179 TUFAIL(
"Threw an unexpected exception type");
190 testFramework.changeSourceMethod(
"GNSSTK_THROW");
191 TUFAIL(
"Did not throw an exception when expected");
195 testFramework.changeSourceMethod(
"GNSSTK_THROW");
197 testFramework.changeSourceMethod(
"getErrorId");
199 testFramework.changeSourceMethod(
"isRecoverable");
200 testFramework.assert(!exc.
isRecoverable(),
"Incorrect severity", __LINE__);
204 testFramework.changeSourceMethod(
"GNSSTK_THROW");
205 TUFAIL(
"Threw an unexpected exception type");
207 return testFramework.countFails();
214 TUDEF(
"Exception",
"macros");
217 testFramework.changeSourceMethod(
"GNSSTK_ASSERT");
221 TUFAIL(
"Did not throw AssertionFailure exception");
223 catch (gnsstk::AssertionFailure &exc)
229 TUFAIL(
"Threw a different exception from AssertionFailure");
233 testFramework.changeSourceMethod(
"NEW_EXCEPTION_CLASS");
236 TestExceptionClass exc(
"moo");
238 TUFAIL(
"Did not throw TestExceptionClass");
240 catch (gnsstk::InvalidParameter)
243 TUPASS(
"NEW_EXCEPTION_CLASS");
247 TUFAIL(
"Threw a different exception from InvalidParameter");
251 testFramework.changeSourceMethod(
"GNSSTK_RETHROW");
254 rethrowSomething(testFramework);
255 TUFAIL(
"rethrowSomething didn't throw exception");
257 catch(gnsstk::InvalidRequest& exc)
259 TUASSERTE(
size_t, 2, exc.getLocationCount());
260 if (exc.getLocationCount() == 2)
270 TUFAIL(
"rethrowSomething threw unexpected exception type");
273 return testFramework.countFails();
281 TUDEF(
typeid(EXC).name(),
"GNSSTK_THROW");
286 TUFAIL(
"Did not throw an exception when expected");
301 TUFAIL(
"Threw an unexpected exception type");
303 return testFramework.countFails();
310 gnsstk::InvalidRequest exc(
"cow");
320 throwSomething(testFramework);
321 TUFAIL(
"throwSomething didn't throw exception");
323 catch (gnsstk::InvalidRequest &exc)
330 TUFAIL(
"throwSomething threw unexpected exception type");
335 int main(
int argc,
char *argv[])
344 cout <<
"Total Failures for " << __FILE__ <<
": " << errorTotal << endl;