diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2017-05-07 08:30:10 +1000 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2017-05-07 08:30:10 +1000 |
commit | f81e6f5c78686be9d58174800983012ec025b849 (patch) | |
tree | 6ce56eaec7c45fabc64b5f32a6a652f48bda65f5 /stoc | |
parent | 3cf126d701484c8141f9c64e87127f3e858c2aef (diff) |
tdf#43157: convert stoc tests from OSL_ASSERT to assert
Change-Id: Ibe34f5c62897d753150d7e302767126980a17552
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/test/tdmanager/testtdmanager.cxx | 2 | ||||
-rw-r--r-- | stoc/test/testconv.cxx | 6 | ||||
-rw-r--r-- | stoc/test/testcorefl.cxx | 4 | ||||
-rw-r--r-- | stoc/test/testiadapter.cxx | 12 | ||||
-rw-r--r-- | stoc/test/testproxyfac.cxx | 30 | ||||
-rw-r--r-- | stoc/test/testregistry.cxx | 94 | ||||
-rw-r--r-- | stoc/test/testsmgr2.cxx | 4 |
7 files changed, 78 insertions, 74 deletions
diff --git a/stoc/test/tdmanager/testtdmanager.cxx b/stoc/test/tdmanager/testtdmanager.cxx index e466904b4314..e09c8297ceae 100644 --- a/stoc/test/tdmanager/testtdmanager.cxx +++ b/stoc/test/tdmanager/testtdmanager.cxx @@ -130,7 +130,7 @@ sal_Int32 Service::run(css::uno::Sequence< OUString > const & arguments) // test: add cmd line rdbs to manager - OSL_ASSERT( arguments.getLength() > 0 ); + assert( arguments.getLength() > 0 ); css::uno::Reference<css::container::XSet> xSet( manager, css::uno::UNO_QUERY_THROW ); for ( sal_Int32 argPos = 0; argPos < arguments.getLength(); ++argPos ) { diff --git a/stoc/test/testconv.cxx b/stoc/test/testconv.cxx index 1e9aae16ed42..bbca4088d856 100644 --- a/stoc/test/testconv.cxx +++ b/stoc/test/testconv.cxx @@ -642,13 +642,13 @@ static void test_Conversion( const Reference< XMultiServiceFactory > & xMgr ) aRet = xConverter->convertTo( aRet, cppu::UnoType<XServiceInfo>::get()); aRet <<= SAL_CONST_INT64(0x7fffffffffffffff); aRet = xConverter->convertTo( aRet, cppu::UnoType<sal_uInt64>::get()); - OSL_ASSERT( *(const sal_uInt64 *)aRet.getValue() == SAL_CONST_UINT64(0x7fffffffffffffff) ); + assert( *(const sal_uInt64 *)aRet.getValue() == SAL_CONST_UINT64(0x7fffffffffffffff) ); aRet <<= SAL_CONST_UINT64(0xffffffffffffffff); aRet = xConverter->convertTo( aRet, cppu::UnoType<sal_uInt64>::get()); - OSL_ASSERT( *(const sal_uInt64 *)aRet.getValue() == SAL_CONST_UINT64(0xffffffffffffffff) ); + assert( *(const sal_uInt64 *)aRet.getValue() == SAL_CONST_UINT64(0xffffffffffffffff) ); aRet <<= SAL_CONST_INT64(-1); aRet = xConverter->convertTo( aRet, cppu::UnoType<sal_Int8>::get()); - OSL_ASSERT( *(const sal_Int8 *)aRet.getValue() == (-1) ); + assert( *(const sal_Int8 *)aRet.getValue() == (-1) ); printf( "test_Conversion(): end.\n" ); } diff --git a/stoc/test/testcorefl.cxx b/stoc/test/testcorefl.cxx index 3b2a02cccd8a..df6542407d38 100644 --- a/stoc/test/testcorefl.cxx +++ b/stoc/test/testcorefl.cxx @@ -348,11 +348,11 @@ SAL_IMPLEMENT_MAIN() OUString( "stoctest.rdb" ) ) ); Reference< XComponentContext > xContext; Reference< beans::XPropertySet > xProps( xMgr, UNO_QUERY ); - OSL_ASSERT( xProps.is() ); + assert( xProps.is() ); xProps->getPropertyValue( OUString( "DefaultContext" ) ) >>= xContext; - OSL_ASSERT( xContext.is() ); + assert( xContext.is() ); Reference< XIdlReflection > xRefl; xContext->getValueByName( diff --git a/stoc/test/testiadapter.cxx b/stoc/test/testiadapter.cxx index a335939b9659..df947c5b5124 100644 --- a/stoc/test/testiadapter.cxx +++ b/stoc/test/testiadapter.cxx @@ -309,8 +309,8 @@ Any XLB_Invocation::invoke( const OUString & rFunctionName, Any aRet; - OSL_ASSERT( rOutParam.getLength() == 0 ); - OSL_ASSERT( rOutParamIndex.getLength() == 0 ); + assert( rOutParam.getLength() == 0 ); + assert( rOutParamIndex.getLength() == 0 ); try { @@ -334,7 +334,7 @@ Any XLB_Invocation::invoke( const OUString & rFunctionName, if ( rFunctionName == "setValues" ) { - OSL_ASSERT( rParams.getLength() == 17 ); + assert( rParams.getLength() == 17 ); aBool = *(sal_Bool *)rParams[0].getValue(); aChar = *(sal_Unicode *)rParams[1].getValue(); rParams[2] >>= nByte; @@ -781,7 +781,7 @@ sal_Bool performTest( const Reference<XLanguageBindingTest > & xLBT ) aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double, aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 ); - OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) ); + assert( equals( aData, aRet ) && equals( aData, aRet2 ) ); // set last retrieved values test::TestData aSV2ret = xLBT->setValues2( @@ -789,7 +789,7 @@ sal_Bool performTest( const Reference<XLanguageBindingTest > & xLBT ) aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double, aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 ); - OSL_ASSERT( equals( aData, aSV2ret ) && equals( aData, aRet2 ) ); + assert( equals( aData, aSV2ret ) && equals( aData, aRet2 ) ); } { test::TestData aRet, aRet2; @@ -798,7 +798,7 @@ sal_Bool performTest( const Reference<XLanguageBindingTest > & xLBT ) aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double, aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 ); - OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) && equals( aData, aGVret ) ); + assert( equals( aData, aRet ) && equals( aData, aRet2 ) && equals( aData, aGVret ) ); // set last retrieved values xLBT->setBool( aRet.Bool ); diff --git a/stoc/test/testproxyfac.cxx b/stoc/test/testproxyfac.cxx index ebc878696316..7579dce79631 100644 --- a/stoc/test/testproxyfac.cxx +++ b/stoc/test/testproxyfac.cxx @@ -172,7 +172,7 @@ static void test_proxyfac_( (void)test; Reference< lang::XServiceInfo > xMaster_XServiceInfo( xMaster, UNO_QUERY_THROW ); - OSL_ASSERT( xMaster_XServiceInfo->getImplementationName().equals( test ) ); + assert( xMaster_XServiceInfo->getImplementationName().equals( test ) ); Reference< reflection::XProxyFactory > xTarget( xMaster, UNO_QUERY_THROW ); Reference< XCurrentContext > xTarget_XCurrentContext( @@ -180,34 +180,34 @@ static void test_proxyfac_( Reference< XCurrentContext > xMaster_XCurrentContext( xMaster, UNO_QUERY_THROW ); - OSL_ASSERT( + assert( xTarget_XCurrentContext->getValueByName( test ) == makeAny( test ) ); - OSL_ASSERT( + assert( xMaster_XCurrentContext->getValueByName( test ) == makeAny( test ) ); Reference< XAggregation > xFakeAgg( xTarget->createProxy( xTarget ) ); if (xFakeAgg.is()) { - OSL_ASSERT( xTarget == xFakeAgg ); - OSL_ASSERT( xMaster == xFakeAgg ); + assert( xTarget == xFakeAgg ); + assert( xMaster == xFakeAgg ); } Reference< lang::XServiceInfo > xTarget_XServiceInfo( xTarget, UNO_QUERY_THROW ); - OSL_ASSERT( xTarget_XServiceInfo->getImplementationName().equals( test ) ); + assert( xTarget_XServiceInfo->getImplementationName().equals( test ) ); Reference< lang::XServiceInfo > xTarget_XServiceInfo2( xTarget, UNO_QUERY_THROW ); - OSL_ASSERT( xTarget_XServiceInfo2.get() == xTarget_XServiceInfo.get() ); + assert( xTarget_XServiceInfo2.get() == xTarget_XServiceInfo.get() ); - OSL_ASSERT( xTarget == xTarget_XCurrentContext ); - OSL_ASSERT( xTarget_XCurrentContext == xMaster ); - OSL_ASSERT( + assert( xTarget == xTarget_XCurrentContext ); + assert( xTarget_XCurrentContext == xMaster ); + assert( xTarget_XCurrentContext.get() == xMaster_XCurrentContext.get() ); - OSL_ASSERT( xTarget_XCurrentContext == xMaster ); - OSL_ASSERT( xTarget == xMaster ); - OSL_ASSERT( xTarget_XServiceInfo.get() == xMaster_XServiceInfo.get() ); - OSL_ASSERT( xTarget_XServiceInfo == xMaster ); - OSL_ASSERT( xMaster_XServiceInfo == xMaster ); + assert( xTarget_XCurrentContext == xMaster ); + assert( xTarget == xMaster ); + assert( xTarget_XServiceInfo.get() == xMaster_XServiceInfo.get() ); + assert( xTarget_XServiceInfo == xMaster ); + assert( xMaster_XServiceInfo == xMaster ); try { diff --git a/stoc/test/testregistry.cxx b/stoc/test/testregistry.cxx index b2dd4dd7051e..dfeeff42189e 100644 --- a/stoc/test/testregistry.cxx +++ b/stoc/test/testregistry.cxx @@ -55,33 +55,36 @@ using namespace osl; namespace stoc_impreg { void SAL_CALL mergeKeys( -Reference< registry::XRegistryKey > const & xDest, -Reference< registry::XRegistryKey > const & xSource ); + Reference< registry::XRegistryKey > const & xDest, + Reference< registry::XRegistryKey > const & xSource ); } + static void mergeKeys( -Reference< registry::XSimpleRegistry > const & xDest, -OUString const & rBaseNode, -OUString const & rURL ) -{ -Reference< registry::XRegistryKey > xDestRoot( xDest->getRootKey() ); -Reference< registry::XRegistryKey > xDestKey; -if (rBaseNode.getLength()) + Reference< registry::XSimpleRegistry > const & xDest, + OUString const & rBaseNode, + OUString const & rURL ) { -xDestKey = xDestRoot->createKey( rBaseNode ); -xDestRoot->closeKey(); -} -else -{ -xDestKey = xDestRoot; -} -Reference< registry::XSimpleRegistry > xSimReg( ::cppu::createSimpleRegistry() ); -xSimReg->open( rURL, sal_True, sal_False ); -OSL_ASSERT( xSimReg->isValid() ); -Reference< registry::XRegistryKey > xSourceKey( xSimReg->getRootKey() ); -::stoc_impreg::mergeKeys( xDestKey, xSourceKey ); -xSourceKey->closeKey(); -xSimReg->close(); -xDestKey->closeKey(); + Reference< registry::XRegistryKey > xDestRoot( xDest->getRootKey() ); + Reference< registry::XRegistryKey > xDestKey; + + if (rBaseNode.getLength()) + { + xDestKey = xDestRoot->createKey( rBaseNode ); + xDestRoot->closeKey(); + } + else + { + xDestKey = xDestRoot; + } + + Reference< registry::XSimpleRegistry > xSimReg( ::cppu::createSimpleRegistry() ); + xSimReg->open( rURL, sal_True, sal_False ); + assert( xSimReg->isValid() ); + Reference< registry::XRegistryKey > xSourceKey( xSimReg->getRootKey() ); + ::stoc_impreg::mergeKeys( xDestKey, xSourceKey ); + xSourceKey->closeKey(); + xSimReg->close(); + xDestKey->closeKey(); } @@ -89,33 +92,34 @@ OString userRegEnv("STAR_USER_REGISTRY="); OUString getExePath() { -OUString exe; -OSL_VERIFY( osl_getExecutableFile( &exe.pData ) == osl_Process_E_None); + OUString exe; + OSL_VERIFY( osl_getExecutableFile( &exe.pData ) == osl_Process_E_None); #if defined(_WIN32) -exe = exe.copy(0, exe.getLength() - 16); + exe = exe.copy(0, exe.getLength() - 16); #else -exe = exe.copy(0, exe.getLength() - 12); + exe = exe.copy(0, exe.getLength() - 12); #endif -return exe; + return exe; } void setStarUserRegistry() { -Registry *myRegistry = new Registry(); + Registry *myRegistry = new Registry(); -RegistryKey rootKey, rKey, rKey2; + RegistryKey rootKey, rKey, rKey2; -OUString userReg = getExePath(); -userReg += "user.rdb"; -if(myRegistry->open(userReg, RegAccessMode::READWRITE)) -{ -OSL_VERIFY(!myRegistry->create(userReg)); -} + OUString userReg = getExePath(); + userReg += "user.rdb"; -OSL_VERIFY(!myRegistry->close()); -delete myRegistry; + if(myRegistry->open(userReg, RegAccessMode::READWRITE)) + { + OSL_VERIFY(!myRegistry->create(userReg)); + } + + OSL_VERIFY(!myRegistry->close()); + delete myRegistry; -userRegEnv += OUStringToOString(userReg, RTL_TEXTENCODING_ASCII_US); + userRegEnv += OUStringToOString(userReg, RTL_TEXTENCODING_ASCII_US); putenv((char *)userRegEnv.getStr()); } @@ -646,7 +650,7 @@ void test_DefaultRegistry( SAL_IMPLEMENT_MAIN() { // setStarUserRegistry(); - setLinkInDefaultRegistry(OUString("/Test/DefaultLink"), + setLinkInDefaultRegistry(OUString("/Test/DefaultLink"), OUString("/Test/FifthKey/MyFirstLink")); OUString reg1( "testreg1.rdb" ); @@ -654,10 +658,10 @@ SAL_IMPLEMENT_MAIN() OUString areg1( "atestreg1.rdb" ); OUString areg2( "atestreg2.rdb" ); - test_SimpleRegistry( reg1, reg2 ); - test_DefaultRegistry( reg1, reg2 ); - test_SimpleRegistry( areg1, areg2, true ); // use different merge - test_DefaultRegistry( areg1, areg2, true ); + test_SimpleRegistry( reg1, reg2 ); + test_DefaultRegistry( reg1, reg2 ); + test_SimpleRegistry( areg1, areg2, true ); // use different merge + test_DefaultRegistry( areg1, areg2, true ); Reference< XSimpleRegistry > xSimReg( ::cppu::createSimpleRegistry() ); xSimReg->open( reg1, sal_False, sal_True ); diff --git a/stoc/test/testsmgr2.cxx b/stoc/test/testsmgr2.cxx index 2e40c0444dca..dd65f6733724 100644 --- a/stoc/test/testsmgr2.cxx +++ b/stoc/test/testsmgr2.cxx @@ -76,7 +76,7 @@ SAL_IMPLEMENT_MAIN() n ++; } // there are two services in two registries ! - OSL_ASSERT( 2 == n ); + assert( 2 == n ); if( 2 == n ) { printf( "test passed\n" ); @@ -101,7 +101,7 @@ SAL_IMPLEMENT_MAIN() { OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); printf( "%s\n" , o.getStr() ); - OSL_ASSERT( 0 ); + assert(0); return 1; } } |