X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=blobdiff_plain;f=xmltoolingtest%2FExceptionTest.h;h=a3bd6aeeb06d7be0edab4e1017034dd7a6cc2999;hp=d681577e402a624dc55c170c5ec8f1c6fbbda455;hb=HEAD;hpb=4d48e7c4f1f95891d4ef5004dda17311648e9724 diff --git a/xmltoolingtest/ExceptionTest.h b/xmltoolingtest/ExceptionTest.h index d681577..a3bd6ae 100644 --- a/xmltoolingtest/ExceptionTest.h +++ b/xmltoolingtest/ExceptionTest.h @@ -1,52 +1,53 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "XMLObjectBaseTestCase.h" - -#include - - -class ExceptionTest : public CxxTest::TestSuite { -public: - - void testException(void) { - TS_TRACE("testException"); - -#define TEST(n,b,a) XMLToolingException e##n(b); \ - TS_ASSERT(!strcmp(a,e##n.what())) - -#define TESTP(n,b,a,p) MarshallingException e##n(b,p); \ - TS_ASSERT(!strcmp(a,e##n.what())) - - - TESTP(1,"This is a test.", "This is a test.", params(2,"Foo","bar")); - TESTP(2,"This is a test.$", "This is a test.", params(2,"Foo","bar")); - TESTP(3,"This is a $ test.", "This is a test.", params(2,"Foo","bar")); - TESTP(4,"$$This is a test.$", "$This is a test.", params(2,"Foo","bar")); - TESTP(5,"$This is a $test.", "This is a test.", params(2,"Foo","bar")); - TESTP(6,"$1 is a $2", "Foo is a bar", params(2,"Foo","bar")); - TESTP(7,"$This is a $test.", "Foo is a bar.", namedparams(2,"This","Foo","test","bar")); - TESTP(8,"Unable to generate random data: $1", - "Unable to generate random data: OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised", - params(1,"OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised")); - - string buf=e7.toString(); - TS_TRACE(buf.c_str()); - auto_ptr ptr(XMLToolingException::fromString(buf.c_str())); - TS_ASSERT(typeid(*ptr)==typeid(MarshallingException)); - TS_ASSERT(!strcmp(ptr->what(),"Foo is a bar.")); - } -}; +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + * + * UCAID licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the + * License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + */ + +#include "XMLObjectBaseTestCase.h" + +#include + + +class ExceptionTest : public CxxTest::TestSuite { +public: + + void testException(void) { +#define TEST(n,b,a) XMLToolingException e##n(b); \ + TS_ASSERT(!strcmp(a,e##n.what())) + +#define TESTP(n,b,a,p) MarshallingException e##n(b,p); \ + TS_ASSERT(!strcmp(a,e##n.what())) + + + TESTP(1,"This is a test.", "This is a test.", params(2,"Foo","bar")); + TESTP(2,"This is a test.$", "This is a test.", params(2,"Foo","bar")); + TESTP(3,"This is a $ test.", "This is a test.", params(2,"Foo","bar")); + TESTP(4,"$$This is a test.$", "$This is a test.", params(2,"Foo","bar")); + TESTP(5,"$This is a $test.", "This is a test.", params(2,"Foo","bar")); + TESTP(6,"$1 is a $2", "Foo is a bar", params(2,"Foo","bar")); + TESTP(7,"$This is a $test.", "Foo is a bar.", namedparams(2,"This","Foo","test","bar")); + TESTP(8,"Unable to generate random data: $1", + "Unable to generate random data: OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised", + params(1,"OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised")); + + string buf=e7.toString(); + auto_ptr ptr(XMLToolingException::fromString(buf.c_str())); + TS_ASSERT(typeid(*ptr)==typeid(MarshallingException)); + TS_ASSERT(!strcmp(ptr->what(),"Foo is a bar.")); + } +};