Kaydet (Commit) 93dbde52 authored tarafından Damjan Jovanovic's avatar Damjan Jovanovic

#i125003# migrate main/stoc/test/uriproc from cppunit to Google Test

üst d7b7943a
...@@ -35,18 +35,22 @@ my_components = stocservices ...@@ -35,18 +35,22 @@ my_components = stocservices
.INCLUDE: settings.mk .INCLUDE: settings.mk
CFLAGSCXX += $(CPPUNIT_CFLAGS) .IF "$(ENABLE_UNIT_TESTS)" != "YES"
all:
@echo unit tests are disabled. Nothing to do.
.ELSE
DLLPRE = # no leading "lib" on .so files DLLPRE = # no leading "lib" on .so files
SHL1TARGET = $(TARGET) APP1TARGET = $(TARGET)
SHL1OBJS = $(SLO)/test_uriproc.obj APP1OBJS = $(SLO)/test_uriproc.obj
SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) APP1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(GTESTLIB) $(SALLIB)
SHL1VERSIONMAP = version.map APP1RPATH = NONE
SHL1RPATH = NONE # this is a custom test, can't use APP1TARGET_run so disable it here:
SHL1IMPLIB = i$(SHL1TARGET) APP1TEST = disabled
DEF1NAME = $(SHL1TARGET)
SLOFILES = $(SHL1OBJS) SLOFILES = $(APP1OBJS)
.INCLUDE: target.mk .INCLUDE: target.mk
...@@ -59,10 +63,11 @@ my_file = file:// ...@@ -59,10 +63,11 @@ my_file = file://
ALLTAR: test ALLTAR: test
test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/services.rdb test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/services.rdb
$(CPPUNITTESTER) $(SHL1TARGETN) \ $(COMMAND_ECHO) $(AUGMENT_LIBRARY_PATH_LOCAL) \
-env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb \ UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb \
-env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \ UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \
-env:URE_INTERNAL_LIB_DIR=$(my_file)$(PWD)/$(DLLDEST) URE_INTERNAL_LIB_DIR=$(my_file)$(PWD)/$(DLLDEST) \
$(APP1TARGETN) --gtest_output="xml:$(BIN)/$(APP1TARGET)_result.xml"
$(MISC)/$(TARGET)/services.rdb .ERRREMOVE: $(SOLARENV)/bin/packcomponents.xslt \ $(MISC)/$(TARGET)/services.rdb .ERRREMOVE: $(SOLARENV)/bin/packcomponents.xslt \
$(MISC)/$(TARGET)/services.input \ $(MISC)/$(TARGET)/services.input \
...@@ -76,4 +81,6 @@ $(MISC)/$(TARGET)/services.input: ...@@ -76,4 +81,6 @@ $(MISC)/$(TARGET)/services.input:
'<list>$(my_components:^"<filename>":+".component</filename>")</list>' \ '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \
> $@ > $@
.END .ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
.ENDIF # "$(OOO_SUBSEQUENT_TESTS)" == ""
...@@ -39,11 +39,9 @@ ...@@ -39,11 +39,9 @@
#include "com/sun/star/uri/XVndSunStarScriptUrlReference.hpp" #include "com/sun/star/uri/XVndSunStarScriptUrlReference.hpp"
#include "com/sun/star/util/XMacroExpander.hpp" #include "com/sun/star/util/XMacroExpander.hpp"
#include "cppuhelper/bootstrap.hxx" #include "cppuhelper/bootstrap.hxx"
#include "cppunit/TestAssert.h" #include "gtest/gtest.h"
#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
#include "osl/diagnose.h" #include "osl/diagnose.h"
#include "osl/process.h"
#include "rtl/string.h" #include "rtl/string.h"
#include "rtl/string.hxx" #include "rtl/string.hxx"
#include "rtl/textenc.h" #include "rtl/textenc.h"
...@@ -58,11 +56,11 @@ namespace css = com::sun::star; ...@@ -58,11 +56,11 @@ namespace css = com::sun::star;
namespace { namespace {
#define TEST_ASSERT_EQUAL(token1, token2, token3, expected, actual) \ #define TEST_ASSERT_EQUAL(token1, token2, token3, expected, actual) \
CPPUNIT_ASSERT_MESSAGE( \ ASSERT_TRUE( \
(actual) == (expected)) << \
createTestAssertEqualMessage( \ createTestAssertEqualMessage( \
token1, token2, token3, #expected, #actual, expected, actual). \ token1, token2, token3, #expected, #actual, expected, actual). \
getStr(), \ getStr()
(actual) == (expected))
template< typename T > void append( template< typename T > void append(
rtl::OUStringBuffer & buffer, T const & value) rtl::OUStringBuffer & buffer, T const & value)
...@@ -109,53 +107,29 @@ rtl::OString createTestAssertEqualMessage( ...@@ -109,53 +107,29 @@ rtl::OString createTestAssertEqualMessage(
buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US); buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US);
} }
class Test: public CppUnit::TestFixture { class Test: public ::testing::Test {
public: public:
virtual void setUp(); virtual void SetUp();
virtual void tearDown(); virtual void TearDown();
void testParse(); protected:
void testMakeAbsolute();
void testMakeRelative();
void testVndSunStarExpand();
void testVndSunStarScript();
void testTranslator();
void testPkgUrlFactory();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testParse);
CPPUNIT_TEST(testMakeAbsolute);
CPPUNIT_TEST(testMakeRelative);
CPPUNIT_TEST(testVndSunStarExpand);
CPPUNIT_TEST(testVndSunStarScript);
CPPUNIT_TEST(testTranslator);
CPPUNIT_TEST(testPkgUrlFactory);
CPPUNIT_TEST_SUITE_END();
private:
css::uno::Reference< css::uno::XComponentContext > m_context; css::uno::Reference< css::uno::XComponentContext > m_context;
css::uno::Reference< css::uri::XUriReferenceFactory > m_uriFactory; css::uno::Reference< css::uri::XUriReferenceFactory > m_uriFactory;
}; };
void Test::setUp() { void Test::SetUp() {
m_context = cppu::defaultBootstrap_InitialComponentContext(); m_context = cppu::defaultBootstrap_InitialComponentContext();
m_uriFactory = css::uri::UriReferenceFactory::create(m_context); m_uriFactory = css::uri::UriReferenceFactory::create(m_context);
} }
void Test::tearDown() { void Test::TearDown() {
m_uriFactory.clear(); m_uriFactory.clear();
css::uno::Reference< css::lang::XComponent >( css::uno::Reference< css::lang::XComponent >(
m_context, css::uno::UNO_QUERY_THROW)->dispose(); m_context, css::uno::UNO_QUERY_THROW)->dispose();
} }
void Test::testParse() { TEST_F(Test, testParse) {
struct Data { struct Data {
char const * uriReference; char const * uriReference;
char const * scheme; char const * scheme;
...@@ -204,7 +178,7 @@ void Test::testParse() { ...@@ -204,7 +178,7 @@ void Test::testParse() {
css::uno::Reference< css::uri::XUriReference > uriRef( css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse( m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference))); rtl::OUString::createFromAscii(data[i].uriReference)));
CPPUNIT_ASSERT(uriRef.is() == (data[i].schemeSpecificPart != 0)); ASSERT_TRUE(uriRef.is() == (data[i].schemeSpecificPart != 0));
if (uriRef.is()) { if (uriRef.is()) {
TEST_ASSERT_EQUAL( TEST_ASSERT_EQUAL(
"testParse", i, data[i].uriReference, "testParse", i, data[i].uriReference,
...@@ -291,7 +265,7 @@ void Test::testParse() { ...@@ -291,7 +265,7 @@ void Test::testParse() {
} }
} }
void Test::testMakeAbsolute() { TEST_F(Test, testMakeAbsolute) {
struct Data { struct Data {
char const * baseUriReference; char const * baseUriReference;
char const * uriReference; char const * uriReference;
...@@ -594,11 +568,11 @@ void Test::testMakeAbsolute() { ...@@ -594,11 +568,11 @@ void Test::testMakeAbsolute() {
css::uno::Reference< css::uri::XUriReference > baseUriRef( css::uno::Reference< css::uri::XUriReference > baseUriRef(
m_uriFactory->parse( m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].baseUriReference))); rtl::OUString::createFromAscii(data[i].baseUriReference)));
CPPUNIT_ASSERT(baseUriRef.is()); ASSERT_TRUE(baseUriRef.is());
css::uno::Reference< css::uri::XUriReference > uriRef( css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse( m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference))); rtl::OUString::createFromAscii(data[i].uriReference)));
CPPUNIT_ASSERT(uriRef.is()); ASSERT_TRUE(uriRef.is());
css::uno::Reference< css::uri::XUriReference > absolute( css::uno::Reference< css::uri::XUriReference > absolute(
m_uriFactory->makeAbsolute( m_uriFactory->makeAbsolute(
baseUriRef, uriRef, data[i].processSpecialBaseSegments, baseUriRef, uriRef, data[i].processSpecialBaseSegments,
...@@ -615,7 +589,7 @@ void Test::testMakeAbsolute() { ...@@ -615,7 +589,7 @@ void Test::testMakeAbsolute() {
} }
} }
void Test::testMakeRelative() { TEST_F(Test, testMakeRelative) {
struct Data { struct Data {
char const * baseUriReference; char const * baseUriReference;
char const * uriReference; char const * uriReference;
...@@ -699,11 +673,11 @@ void Test::testMakeRelative() { ...@@ -699,11 +673,11 @@ void Test::testMakeRelative() {
css::uno::Reference< css::uri::XUriReference > baseUriRef( css::uno::Reference< css::uri::XUriReference > baseUriRef(
m_uriFactory->parse( m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].baseUriReference))); rtl::OUString::createFromAscii(data[i].baseUriReference)));
CPPUNIT_ASSERT(baseUriRef.is()); ASSERT_TRUE(baseUriRef.is());
css::uno::Reference< css::uri::XUriReference > uriRef( css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse( m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference))); rtl::OUString::createFromAscii(data[i].uriReference)));
CPPUNIT_ASSERT(uriRef.is()); ASSERT_TRUE(uriRef.is());
css::uno::Reference< css::uri::XUriReference > relative( css::uno::Reference< css::uri::XUriReference > relative(
m_uriFactory->makeRelative( m_uriFactory->makeRelative(
baseUriRef, uriRef, data[i].preferAuthorityOverRelativePath, baseUriRef, uriRef, data[i].preferAuthorityOverRelativePath,
...@@ -721,7 +695,7 @@ void Test::testMakeRelative() { ...@@ -721,7 +695,7 @@ void Test::testMakeRelative() {
m_uriFactory->makeAbsolute( m_uriFactory->makeAbsolute(
baseUriRef, relative, true, baseUriRef, relative, true,
css::uri::RelativeUriExcessParentSegments_ERROR)); css::uri::RelativeUriExcessParentSegments_ERROR));
CPPUNIT_ASSERT(absolute.is()); ASSERT_TRUE(absolute.is());
TEST_ASSERT_EQUAL( TEST_ASSERT_EQUAL(
"testMakeRelative", i, data[i].uriReference, "testMakeRelative", i, data[i].uriReference,
rtl::OUString::createFromAscii( rtl::OUString::createFromAscii(
...@@ -732,7 +706,7 @@ void Test::testMakeRelative() { ...@@ -732,7 +706,7 @@ void Test::testMakeRelative() {
} }
} }
void Test::testVndSunStarExpand() { TEST_F(Test, testVndSunStarExpand) {
struct Data { struct Data {
char const * uriReference; char const * uriReference;
char const * expanded; char const * expanded;
...@@ -766,7 +740,7 @@ void Test::testVndSunStarExpand() { ...@@ -766,7 +740,7 @@ void Test::testVndSunStarExpand() {
} }
} }
void Test::testVndSunStarScript() { TEST_F(Test, testVndSunStarScript) {
struct Parameter { struct Parameter {
char const * key; char const * key;
char const * value; char const * value;
...@@ -920,7 +894,7 @@ void Test::testVndSunStarScript() { ...@@ -920,7 +894,7 @@ void Test::testVndSunStarScript() {
true); true);
} }
void Test::testTranslator() { TEST_F(Test, testTranslator) {
struct Data { struct Data {
char const * externalUriReference; char const * externalUriReference;
char const * internalUriReference; char const * internalUriReference;
...@@ -964,7 +938,7 @@ void Test::testTranslator() { ...@@ -964,7 +938,7 @@ void Test::testTranslator() {
} }
} }
void Test::testPkgUrlFactory() { TEST_F(Test, testPkgUrlFactory) {
struct Data { struct Data {
char const * authority; char const * authority;
char const * result; char const * result;
...@@ -993,8 +967,12 @@ void Test::testPkgUrlFactory() { ...@@ -993,8 +967,12 @@ void Test::testPkgUrlFactory() {
} }
} }
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
} }
CPPUNIT_PLUGIN_IMPLEMENT(); int main(int argc, char **argv)
{
osl_setCommandArgs(argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment