2 * Copyright 2001-2005 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 #include "XMLObjectBaseTestCase.h"
\r
19 #include <xmltooling/exceptions.h>
\r
22 class ExceptionTest : public CxxTest::TestSuite {
\r
25 void testException(void) {
\r
26 #define TEST(n,b,a) XMLToolingException e##n(b); \
\r
27 TS_ASSERT(!strcmp(a,e##n.what()))
\r
29 #define TESTP(n,b,a,p) MarshallingException e##n(b,p); \
\r
30 TS_ASSERT(!strcmp(a,e##n.what()))
\r
33 TESTP(1,"This is a test.", "This is a test.", params(2,"Foo","bar"));
\r
34 TESTP(2,"This is a test.$", "This is a test.", params(2,"Foo","bar"));
\r
35 TESTP(3,"This is a $ test.", "This is a test.", params(2,"Foo","bar"));
\r
36 TESTP(4,"$$This is a test.$", "$This is a test.", params(2,"Foo","bar"));
\r
37 TESTP(5,"$This is a $test.", "This is a test.", params(2,"Foo","bar"));
\r
38 TESTP(6,"$1 is a $2", "Foo is a bar", params(2,"Foo","bar"));
\r
39 TESTP(7,"$This is a $test.", "Foo is a bar.", namedparams(2,"This","Foo","test","bar"));
\r
40 TESTP(8,"Unable to generate random data: $1",
\r
41 "Unable to generate random data: OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised",
\r
42 params(1,"OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised"));
\r
44 string buf=e7.toString();
\r
45 auto_ptr<XMLToolingException> ptr(XMLToolingException::fromString(buf.c_str()));
\r
46 TS_ASSERT(typeid(*ptr)==typeid(MarshallingException));
\r
47 TS_ASSERT(!strcmp(ptr->what(),"Foo is a bar."));
\r