Author: damjan Date: Wed Oct 14 17:58:56 2015 New Revision: 1708664 URL: http://svn.apache.org/viewvc?rev=1708664&view=rev Log: #i125003# migrate main/xmlsecurity/qa from cppunit to Google Test. Needs neon which is copyleft; doesn't compile; but isn't run during the build.
Removed: openoffice/trunk/main/xmlsecurity/qa/certext/export.map Modified: openoffice/trunk/main/xmlsecurity/qa/certext/SanCertExt.cxx openoffice/trunk/main/xmlsecurity/qa/certext/makefile.mk Modified: openoffice/trunk/main/xmlsecurity/qa/certext/SanCertExt.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/xmlsecurity/qa/certext/SanCertExt.cxx?rev=1708664&r1=1708663&r2=1708664&view=diff ============================================================================== --- openoffice/trunk/main/xmlsecurity/qa/certext/SanCertExt.cxx (original) +++ openoffice/trunk/main/xmlsecurity/qa/certext/SanCertExt.cxx Wed Oct 14 17:58:56 2015 @@ -37,10 +37,7 @@ #include "com/sun/star/uno/Reference.hxx" #include "cppuhelper/bootstrap.hxx" -#include "cppunit/TestAssert.h" -#include "cppunit/TestFixture.h" -#include "cppunit/extensions/HelperMacros.h" -#include "cppunit/plugin/TestPlugIn.h" +#include "gtest/gtest.h" #include "sal/types.h" #include "comphelper/sequence.hxx" #include <rtl/ustring.hxx> @@ -55,9 +52,9 @@ using namespace com::sun::star; namespace { - class Test: public CppUnit::TestFixture { + class Test: public ::testing::Test { - private: + protected: static uno::Sequence< security::CertAltNameEntry > altNames; static bool runOnce; @@ -72,45 +69,14 @@ namespace { ~Test(); - virtual void setUp(); + virtual void SetUp(); - virtual void tearDown(); - - void test_Others(); - - void test_RFC822(); - - void test_DNS(); - - void test_Direcory(); - - void test_URI(); - - void test_IP(); - - void test_RID(); - - void test_EDI(); - - void test_X400(); - - CPPUNIT_TEST_SUITE(Test); - CPPUNIT_TEST(test_Others); - CPPUNIT_TEST(test_RFC822); - CPPUNIT_TEST(test_DNS); - CPPUNIT_TEST(test_Direcory); - CPPUNIT_TEST(test_URI); - CPPUNIT_TEST(test_IP); - CPPUNIT_TEST(test_RID); - CPPUNIT_TEST(test_EDI); - CPPUNIT_TEST(test_X400); - CPPUNIT_TEST_SUITE_END(); + virtual void TearDown(); }; uno::Sequence< security::CertAltNameEntry > Test::altNames; bool Test::runOnce = false; - CPPUNIT_TEST_SUITE_REGISTRATION(Test); Test::Test() { @@ -172,14 +138,14 @@ namespace { } - void Test::setUp() { + void Test::SetUp() { } - void Test::tearDown() { + void Test::TearDown() { } - void Test::test_Others() { - CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) ); + TEST_F(Test, test_Others) { + ASSERT_NO_THROW( ASSERT_TRUE( altNames.getLength() > 0 ) ); for(int n = 1; n < altNames.getLength(); n++) { if (altNames[n].Type == security::ExtAltNameType_OTHER_NAME) @@ -187,91 +153,90 @@ namespace { ::com::sun::star::beans::NamedValue otherNameProp; if (altNames[n].Value >>= otherNameProp) { - CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("1.2.3.4"), otherNameProp.Name); + ASSERT_EQ( rtl::OUString::createFromAscii("1.2.3.4"), otherNameProp.Name); uno::Sequence< sal_Int8 > ipAddress; otherNameProp.Value >>= ipAddress; - CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( ipAddress.getLength() > 0 ) ); + ASSERT_NO_THROW( ASSERT_TRUE( ipAddress.getLength() > 0 ) ); } } } } - void Test::test_RFC822() { - CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) ); + TEST_F(Test, test_RFC822) { + ASSERT_NO_THROW( ASSERT_TRUE( altNames.getLength() > 0 ) ); for(int n = 1; n < altNames.getLength(); n++) { if (altNames[n].Type == security::ExtAltNameType_RFC822_NAME) { rtl::OUString value; altNames[n].Value >>= value; - CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("my@other.address"), value); + ASSERT_EQ( rtl::OUString::createFromAscii("my@other.address"), value ); } } } - void Test::test_DNS() { - CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) ); + TEST_F(Test, test_DNS) { + ASSERT_NO_THROW( ASSERT_TRUE( altNames.getLength() > 0 ) ); for(int n = 1; n < altNames.getLength(); n++) { if (altNames[n].Type == security::ExtAltNameType_DNS_NAME) { rtl::OUString value; altNames[n].Value >>= value; - CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("alt.openoffice.org"), value); + ASSERT_EQ( rtl::OUString::createFromAscii("alt.openoffice.org"), value); } } } - void Test::test_Direcory() { + TEST_F(Test, test_Direcory) { // Not implemented } - void Test::test_URI() { - CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) ); + TEST_F(Test, test_URI) { + ASSERT_NO_THROW( ASSERT_TRUE( altNames.getLength() > 0 ) ); for(int n = 1; n < altNames.getLength(); n++) { if (altNames[n].Type == security::ExtAltNameType_URL) { rtl::OUString value; altNames[n].Value >>= value; - CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("http://my.url.here/"), value); + ASSERT_EQ( rtl::OUString::createFromAscii("http://my.url.here/"), value); } } } - void Test::test_IP() { - CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) ); + TEST_F(Test, test_IP) { + ASSERT_NO_THROW( ASSERT_TRUE( altNames.getLength() > 0 ) ); for(int n = 1; n < altNames.getLength(); n++) { if (altNames[n].Type == security::ExtAltNameType_IP_ADDRESS) { uno::Sequence< sal_Int8 > ipAddress; altNames[n].Value >>= ipAddress; - CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( ipAddress.getLength() > 0 ) ); + ASSERT_NO_THROW( ASSERT_TRUE( ipAddress.getLength() > 0 ) ); } } } - void Test::test_RID() { - CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) ); + TEST_F(Test, test_RID) { + ASSERT_NO_THROW( ASSERT_TRUE( altNames.getLength() > 0 ) ); for(int n = 1; n < altNames.getLength(); n++) { if (altNames[n].Type == security::ExtAltNameType_REGISTERED_ID) { rtl::OUString value; altNames[n].Value >>= value; - CPPUNIT_ASSERT( rtl::OUString::createFromAscii("1.2.3.4").equals(value)); + ASSERT_TRUE( rtl::OUString::createFromAscii("1.2.3.4").equals(value)); } } } - void Test::test_EDI() { + TEST_F(Test, test_EDI) { // Not implemented } - void Test::test_X400() { + TEST_F(Test, test_X400) { // Not implemented } } -CPPUNIT_PLUGIN_IMPLEMENT(); Modified: openoffice/trunk/main/xmlsecurity/qa/certext/makefile.mk URL: http://svn.apache.org/viewvc/openoffice/trunk/main/xmlsecurity/qa/certext/makefile.mk?rev=1708664&r1=1708663&r2=1708664&view=diff ============================================================================== --- openoffice/trunk/main/xmlsecurity/qa/certext/makefile.mk (original) +++ openoffice/trunk/main/xmlsecurity/qa/certext/makefile.mk Wed Oct 14 17:58:56 2015 @@ -36,12 +36,15 @@ ENABLE_EXCEPTIONS = TRUE .INCLUDE: settings.mk .INCLUDE : $(PRJ)$/util$/target.pmk -CFLAGSCXX += $(CPPUNIT_CFLAGS) - -SHL1IMPLIB = i$(SHL1TARGET) -SHL1OBJS = $(SLOFILES) -SHL1RPATH = NONE -SHL1STDLIBS = $(CPPUNITLIB) \ +.IF "$(ENABLE_UNIT_TESTS)" != "YES" +all: + @echo unit tests are disabled. Nothing to do. + +.ELSE + +APP1OBJS = $(SLO)/SanCertExt.obj +APP1RPATH = NONE +APP1STDLIBS = $(GTESTLIB) \ $(SALLIB) \ $(NEON3RDLIB) \ $(CPPULIB) \ @@ -52,20 +55,12 @@ SHL1STDLIBS = $(CPPUNITLIB) \ $(COMPHELPERLIB) \ $(TESTLIB) -SHL1TARGET = qa_CertExt -SHL1VERSIONMAP = $(PRJ)/qa/certext/export.map -DEF1NAME = $(SHL1TARGET) - -SLOFILES = $(SLO)/SanCertExt.obj +APP1TARGET = qa_CertExt +APP1TEST = enabled .INCLUDE: target.mk .INCLUDE: installationtest.mk -ALLTAR : cpptest - -cpptest : $(SHL1TARGETN) - -CPPTEST_LIBRARY = $(SHL1TARGETN) - -.END -.END +.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES" +.ENDIF # "$(OOO_SUBSEQUENT_TESTS)" == "" +.ENDIF # "$(ENABLE_NSS_MODULE)" == "NO"