[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sal/qa
Damjan Jovanovic
damjan at apache.org
Sun Aug 30 21:08:05 PDT 2015
sal/qa/rtl/uri/makefile.mk | 39 ++----
sal/qa/rtl/uri/rtl_Uri.cxx | 197 ++++++++++++++-----------------
sal/qa/rtl/uri/rtl_testuri.cxx | 260 +++++++++++++++++------------------------
3 files changed, 225 insertions(+), 271 deletions(-)
New commits:
commit 33abd0564a8a62d8452892d43906c02ef57553ee
Author: Damjan Jovanovic <damjan at apache.org>
Date: Mon Aug 31 02:16:25 2015 +0000
#i125003# migrate main/sal/qa/rtl/uri from cppunit to Google Test.
diff --git a/sal/qa/rtl/uri/makefile.mk b/sal/qa/rtl/uri/makefile.mk
index 78b0c01..30021d6 100644
--- a/sal/qa/rtl/uri/makefile.mk
+++ b/sal/qa/rtl/uri/makefile.mk
@@ -32,40 +32,37 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
CFLAGS+= $(LFS_CFLAGS)
CXXFLAGS+= $(LFS_CFLAGS)
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-
# --- BEGIN --------------------------------------------------------
-SHL1OBJS= \
+APP1OBJS= \
$(SLO)$/rtl_Uri.obj
-SHL1TARGET= rtl_uri_simple
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-
-SHL1IMPLIB= i$(SHL1TARGET)
-DEF1NAME =$(SHL1TARGET)
-SHL1VERSIONMAP = $(PRJ)$/qa$/export.map
+APP1TARGET= rtl_uri_simple
+APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB)
+APP1RPATH = NONE
+APP1TEST = enabled
# END --------------------------------------------------------------
# --- BEGIN --------------------------------------------------------
-SHL2OBJS= \
+APP2OBJS= \
$(SLO)$/rtl_testuri.obj
-SHL2TARGET= rtl_Uri
-SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-
-SHL2IMPLIB= i$(SHL2TARGET)
-DEF2NAME =$(SHL2TARGET)
-SHL2VERSIONMAP = $(PRJ)$/qa$/export.map
+APP2TARGET= rtl_Uri
+APP2STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB)
+APP2RPATH = NONE
+APP2TEST = enabled
# END --------------------------------------------------------------
-#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
-
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
+
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
diff --git a/sal/qa/rtl/uri/rtl_Uri.cxx b/sal/qa/rtl/uri/rtl_Uri.cxx
index 41a4c39..6ef2a0a 100644
--- a/sal/qa/rtl/uri/rtl_Uri.cxx
+++ b/sal/qa/rtl/uri/rtl_Uri.cxx
@@ -31,7 +31,7 @@
#include <osl/thread.h>
#include <osl/file.hxx>
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
// -----------------------------------------------------------------------------
@@ -71,15 +71,16 @@ namespace Stringtest
// -----------------------------------------------------------------------------
- class Convert : public CppUnit::TestFixture
+ class Convert : public ::testing::Test
{
+ protected:
rtl::OUString m_aStr;
public:
/*
rtl::OString toUTF8(rtl::OUString const& _suStr)
{
rtl::OString sStrAsUTF8 = rtl::OUStringToOString(_suStr, RTL_TEXTENCODING_UTF8);
- t_print("%s\n", escapeString(sStrAsUTF8).getStr());
+ printf("%s\n", escapeString(sStrAsUTF8).getStr());
return sStrAsUTF8;
}
*/
@@ -97,7 +98,7 @@ namespace Stringtest
void showContent(rtl::OUString const& _suStr)
{
rtl::OString sStr = convertToOString(_suStr);
- t_print("%s\n", sStr.getStr());
+ printf("%s\n", sStr.getStr());
}
void toUTF8_mech(rtl::OUString const& _suStr, rtl_UriEncodeMechanism _eMechanism)
@@ -123,39 +124,15 @@ namespace Stringtest
void toUTF8(rtl::OUString const& _suStr)
{
- t_print("rtl_UriEncodeIgnoreEscapes \n");
+ printf("rtl_UriEncodeIgnoreEscapes \n");
toUTF8_mech(_suStr, rtl_UriEncodeIgnoreEscapes);
- t_print("\n");
- t_print("# rtl_UriEncodeKeepEscapes\n");
+ printf("\n");
+ printf("# rtl_UriEncodeKeepEscapes\n");
toUTF8_mech(_suStr, rtl_UriEncodeKeepEscapes);
- t_print("\n");
- t_print("# rtl_UriEncodeCheckEscapes\n");
+ printf("\n");
+ printf("# rtl_UriEncodeCheckEscapes\n");
toUTF8_mech(_suStr, rtl_UriEncodeCheckEscapes);
- t_print("\n");
- }
-
- void test_FromUTF8_001()
- {
- // string --> ustring
- rtl::OString sStrUTF8("h%C3%A4llo");
- rtl::OUString suStrUTF8 = rtl::OStringToOUString(sStrUTF8, RTL_TEXTENCODING_ASCII_US);
-
- // UTF8 --> real ustring
- rtl::OUString suStr_UriDecodeToIuri = rtl::Uri::decode(suStrUTF8, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8);
- showContent(suStr_UriDecodeToIuri);
-
- // string --> ustring
- rtl::OString sStr("h\xE4llo");
- rtl::OUString suString = rtl::OStringToOUString(sStr, RTL_TEXTENCODING_ISO_8859_15);
-
- CPPUNIT_ASSERT_MESSAGE("Strings must be equal", suString.equals(suStr_UriDecodeToIuri) == sal_True);
-
- // ustring --> ustring (UTF8)
- rtl::OUString suStr2 = rtl::Uri::encode(suStr_UriDecodeToIuri, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
- showContent(suStr2);
-
- CPPUNIT_ASSERT_MESSAGE("Strings must be equal", suStr2.equals(suStrUTF8) == sal_True);
- // suStr should be equal to suStr2
+ printf("\n");
}
// "%C3%84qypten";
@@ -214,80 +191,96 @@ namespace Stringtest
}
return sType;
}
+ };
+ TEST_F(Convert, test_FromUTF8_001)
+ {
+ // string --> ustring
+ rtl::OString sStrUTF8("h%C3%A4llo");
+ rtl::OUString suStrUTF8 = rtl::OStringToOUString(sStrUTF8, RTL_TEXTENCODING_ASCII_US);
- void test_UTF8_files()
- {
-#ifdef UNX
- rtl::OUString suDirURL(rtl::OUString::createFromAscii("file:///tmp/atestdir"));
-#else /* Windows */
- rtl::OUString suDirURL(rtl::OUString::createFromAscii("file:///c:/temp/atestdir"));
-#endif
- osl::Directory aDir(suDirURL);
- aDir.open();
- if (aDir.isOpen())
- {
- osl::DirectoryItem aItem;
- osl::FileStatus aStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes | osl_FileStatus_Mask_Type);
- while (aDir.getNextItem(aItem) == ::osl::FileBase::E_None)
- {
- if (osl::FileBase::E_None == aItem.getFileStatus(aStatus) &&
- aStatus.isValid(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes))
- {
- rtl::OString sType = getFileTypeName(aStatus);
-
- rtl::OUString suFilename = aStatus.getFileName();
- // rtl::OUString suFullFileURL;
-
- rtl::OUString suStrUTF8 = rtl::Uri::encode(suFilename, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
- rtl::OString sStrUTF8 = convertToOString(suStrUTF8);
- t_print("Type: '%s' file name '%s'\n", sType.getStr(), sStrUTF8.getStr());
- }
- }
- aDir.close();
- }
- else
- {
- rtl::OString sStr;
- sStr = rtl::OUStringToOString(suDirURL, osl_getThreadTextEncoding());
- t_print("can't open dir:'%s'\n", sStr.getStr());
- }
- }
-
- void test_FromUTF8()
- {
- rtl::OString sStr("h%C3%A4llo");
- rtl::OUString suStr = rtl::OStringToOUString(sStr, osl_getThreadTextEncoding());
+ // UTF8 --> real ustring
+ rtl::OUString suStr_UriDecodeToIuri = rtl::Uri::decode(suStrUTF8, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8);
+ showContent(suStr_UriDecodeToIuri);
-// rtl_UriEncodeIgnoreEscapes,
-// rtl_UriEncodeKeepEscapes,
-// rtl_UriEncodeCheckEscapes,
-// rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassRegName, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8);
- rtl::OUString suStr_UriDecodeNone = rtl::Uri::decode(suStr, rtl_UriDecodeNone, RTL_TEXTENCODING_UTF8);
- showContent(suStr_UriDecodeNone);
- toUTF8(suStr_UriDecodeNone);
+ // string --> ustring
+ rtl::OString sStr("h\xE4llo");
+ rtl::OUString suString = rtl::OStringToOUString(sStr, RTL_TEXTENCODING_ISO_8859_15);
- rtl::OUString suStr_UriDecodeToIuri = rtl::Uri::decode(suStr, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8);
- showContent(suStr_UriDecodeToIuri);
- toUTF8(suStr_UriDecodeToIuri);
+ ASSERT_TRUE(suString.equals(suStr_UriDecodeToIuri) == sal_True) << "Strings must be equal";
- rtl::OUString suStr_UriDecodeWithCharset = rtl::Uri::decode(suStr, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
- showContent(suStr_UriDecodeWithCharset);
- toUTF8(suStr_UriDecodeWithCharset);
- }
+ // ustring --> ustring (UTF8)
+ rtl::OUString suStr2 = rtl::Uri::encode(suStr_UriDecodeToIuri, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
+ showContent(suStr2);
- CPPUNIT_TEST_SUITE( Convert );
- CPPUNIT_TEST( test_FromUTF8_001 );
-// CPPUNIT_TEST( test_UTF8_files );
-// CPPUNIT_TEST( test_FromUTF8 );
- CPPUNIT_TEST_SUITE_END( );
- };
+ ASSERT_TRUE(suStr2.equals(suStrUTF8) == sal_True) << "Strings must be equal";
+ // suStr should be equal to suStr2
+ }
+// These tests were commented out in the pre-gtest code:
+// TEST_F(Convert, test_UTF8_files)
+// {
+//#ifdef UNX
+// rtl::OUString suDirURL(rtl::OUString::createFromAscii("file:///tmp/atestdir"));
+//#else /* Windows */
+// rtl::OUString suDirURL(rtl::OUString::createFromAscii("file:///c:/temp/atestdir"));
+//#endif
+// osl::Directory aDir(suDirURL);
+// aDir.open();
+// if (aDir.isOpen())
+// {
+// osl::DirectoryItem aItem;
+// osl::FileStatus aStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes | osl_FileStatus_Mask_Type);
+// while (aDir.getNextItem(aItem) == ::osl::FileBase::E_None)
+// {
+// if (osl::FileBase::E_None == aItem.getFileStatus(aStatus) &&
+// aStatus.isValid(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes))
+// {
+// rtl::OString sType = getFileTypeName(aStatus);
+//
+// rtl::OUString suFilename = aStatus.getFileName();
+// // rtl::OUString suFullFileURL;
+//
+// rtl::OUString suStrUTF8 = rtl::Uri::encode(suFilename, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
+// rtl::OString sStrUTF8 = convertToOString(suStrUTF8);
+// printf("Type: '%s' file name '%s'\n", sType.getStr(), sStrUTF8.getStr());
+// }
+// }
+// aDir.close();
+// }
+// else
+// {
+// rtl::OString sStr;
+// sStr = rtl::OUStringToOString(suDirURL, osl_getThreadTextEncoding());
+// printf("can't open dir:'%s'\n", sStr.getStr());
+// }
+// }
+//
+// TEST_F(Convert, test_FromUTF8)
+// {
+// rtl::OString sStr("h%C3%A4llo");
+// rtl::OUString suStr = rtl::OStringToOUString(sStr, osl_getThreadTextEncoding());
+//
+//// rtl_UriEncodeIgnoreEscapes,
+//// rtl_UriEncodeKeepEscapes,
+//// rtl_UriEncodeCheckEscapes,
+//// rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassRegName, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8);
+// rtl::OUString suStr_UriDecodeNone = rtl::Uri::decode(suStr, rtl_UriDecodeNone, RTL_TEXTENCODING_UTF8);
+// showContent(suStr_UriDecodeNone);
+// toUTF8(suStr_UriDecodeNone);
+//
+// rtl::OUString suStr_UriDecodeToIuri = rtl::Uri::decode(suStr, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8);
+// showContent(suStr_UriDecodeToIuri);
+// toUTF8(suStr_UriDecodeToIuri);
+//
+// rtl::OUString suStr_UriDecodeWithCharset = rtl::Uri::decode(suStr, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
+// showContent(suStr_UriDecodeWithCharset);
+// toUTF8(suStr_UriDecodeWithCharset);
+// }
}
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( Stringtest::Convert, "Stringtest" );
-
-// LLA: doku anpassen!!!
-
-NOADDITIONAL;
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx
index df59c6d..c57fa3c 100644
--- a/sal/qa/rtl/uri/rtl_testuri.cxx
+++ b/sal/qa/rtl/uri/rtl_testuri.cxx
@@ -32,22 +32,17 @@
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
-#include "testshl/simpleheader.hxx"
-
#include <cstddef>
#include <stdio.h>
+#include "gtest/gtest.h"
namespace {
-struct Test: public CppUnit::TestFixture {
- void test_Uri();
-
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test_Uri);
- CPPUNIT_TEST_SUITE_END();
+class Test: public ::testing::Test {
+public:
};
-void Test::test_Uri() {
+TEST_F(Test, test_Uri) {
rtl_UriCharClass const eFirstCharClass = rtl_UriCharClassNone;
rtl_UriCharClass const eLastCharClass = rtl_UriCharClassUnoParamValue;
@@ -80,54 +75,48 @@ void Test::test_Uri() {
eCharClass <= eLastCharClass;
eCharClass = static_cast< rtl_UriCharClass >(eCharClass + 1))
{
- CPPUNIT_ASSERT_MESSAGE(
- "failure 1",
- (rtl::Uri::decode(
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeKeepEscapes,
RTL_TEXTENCODING_ISO_8859_1),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ASCII_US)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 2",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 1";
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_ISO_8859_1),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ASCII_US)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 3",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 2";
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeKeepEscapes,
RTL_TEXTENCODING_ISO_8859_1),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 4",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 3";
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_ISO_8859_1),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 5",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 4";
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeKeepEscapes,
RTL_TEXTENCODING_ISO_8859_1),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 6",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 5";
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_ISO_8859_1),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 6";
}}
aText1 = rtl::OUString(
@@ -169,38 +158,34 @@ void Test::test_Uri() {
eCharClass <= eLastCharClass;
eCharClass = static_cast< rtl_UriCharClass >(eCharClass + 1))
{
- CPPUNIT_ASSERT_MESSAGE(
- "failure 7",
- (rtl::Uri::decode(
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeKeepEscapes,
RTL_TEXTENCODING_ISO_8859_1),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 8",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 7";
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_ISO_8859_1),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 9",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 8";
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeKeepEscapes,
RTL_TEXTENCODING_UTF8),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 10",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 9";
+ ASSERT_TRUE((rtl::Uri::decode(
rtl::Uri::encode(
aText1, eCharClass, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_UTF8),
rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 10";
}}
// Check surrogate handling:
@@ -214,24 +199,21 @@ void Test::test_Uri() {
aText2 = rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"%ED%A0%80" "%F0%90%8F%BF" "%ED%BF%BF" "A"));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 11",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes,
RTL_TEXTENCODING_UTF8)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 12",
- (rtl::Uri::encode(
+ == aText2)) <<
+ "failure 11";
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeKeepEscapes,
RTL_TEXTENCODING_UTF8)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 13",
- (rtl::Uri::encode(
+ == aText2)) <<
+ "failure 12";
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 13";
aText1 = rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
@@ -242,37 +224,33 @@ void Test::test_Uri() {
aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("%ED%BF%BF"));
aBuffer.append(static_cast< sal_Unicode >('A'));
aText2 = aBuffer.makeStringAndClear();
- CPPUNIT_ASSERT_MESSAGE(
- "failure 14",
- (rtl::Uri::decode(aText1, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 15",
- (rtl::Uri::decode(
+ ASSERT_TRUE((rtl::Uri::decode(aText1, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
+ == aText2)) <<
+ "failure 14";
+ ASSERT_TRUE((rtl::Uri::decode(
aText1, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 15";
// Check UTF-8 handling:
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%E0%83%BF"));
// \U+00FF encoded with three instead of two bytes
aText2 = aText1;
- CPPUNIT_ASSERT_MESSAGE(
- "failure 16",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 16";
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%EF%BF%BF"));
// \U+FFFF is no legal character
aText2 = aText1;
- CPPUNIT_ASSERT_MESSAGE(
- "failure 17",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 17";
// Check IURI handling:
@@ -280,21 +258,19 @@ void Test::test_Uri() {
aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("%30"));
aBuffer.append(static_cast< sal_Unicode >(0x00FF));
aText2 = aBuffer.makeStringAndClear();
- CPPUNIT_ASSERT_MESSAGE(
- "failure 18",
- (rtl::Uri::decode(aText1, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
- == aText2));
+ ASSERT_TRUE((rtl::Uri::decode(aText1, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
+ == aText2)) <<
+ "failure 18";
// Check modified rtl_UriCharClassUnoParamValue (removed '[' and ']'):
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[]%5B%5D"));
aText2 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%5B%5D%5B%5D"));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 19",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUnoParamValue, rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_ASCII_US)
- == aText2));
+ == aText2)) <<
+ "failure 19";
// Check Uri::convertRelToAbs:
@@ -380,7 +356,7 @@ void Test::test_Uri() {
aAbs, RTL_TEXTENCODING_UTF8).getStr()),
(aRelToAbsTest[i].pAbs == 0
? "<MALFORMED>" : aRelToAbsTest[i].pAbs));
- CPPUNIT_ASSERT(false);
+ FAIL();
}
}
@@ -390,17 +366,15 @@ void Test::test_Uri() {
sal_Unicode const aText1U[] = { ' ', '!', 0x0401, 0x045F, 0 };
aText1 = rtl::OUString(aText1U);
aText2 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%20!%A1%FF"));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 20",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes,
RTL_TEXTENCODING_ISO_8859_5)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 20a",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 20";
+ ASSERT_TRUE((rtl::Uri::decode(
aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_5)
- == aText1));
+ == aText1)) <<
+ "failure 20a";
}
{
sal_Unicode const aText1U[] = { ' ', '!', 0x0401, 0x0700, 0x045F, 0 };
@@ -408,34 +382,30 @@ void Test::test_Uri() {
sal_Unicode const aText2U[] = {
'%', '2', '0', '!', '%', 'A', '1', 0x0700, '%', 'F', 'F', 0 };
aText2 = rtl::OUString(aText2U);
- CPPUNIT_ASSERT_MESSAGE(
- "failure 21",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes,
RTL_TEXTENCODING_ISO_8859_5)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 21a",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 21";
+ ASSERT_TRUE((rtl::Uri::decode(
aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_5)
- == aText1));
+ == aText1)) <<
+ "failure 21a";
}
{
sal_Unicode const aText1U[] = { ' ', '!', 0x028A, 0xD849, 0xDD13, 0 };
aText1 = rtl::OUString(aText1U);
aText2 = rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("%20!%81%30%B1%33%95%39%C5%37"));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 22",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes,
RTL_TEXTENCODING_GB_18030)
- == aText2));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 22a",
- (rtl::Uri::decode(
+ == aText2)) <<
+ "failure 22";
+ ASSERT_TRUE((rtl::Uri::decode(
aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_GB_18030)
- == aText1));
+ == aText1)) <<
+ "failure 22a";
}
// Check strict mode:
@@ -444,59 +414,53 @@ void Test::test_Uri() {
sal_Unicode const aText1U[] = { ' ', '!', 0x0401, 0x0700, 0x045F, 0 };
aText1 = rtl::OUString(aText1U);
aText2 = rtl::OUString();
- CPPUNIT_ASSERT_MESSAGE(
- "failure 23",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeStrict,
RTL_TEXTENCODING_ISO_8859_5)
- == aText2));
+ == aText2)) <<
+ "failure 23";
}
{
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%20%C4%80%FF"));
aText2 = rtl::OUString();
- CPPUNIT_ASSERT_MESSAGE(
- "failure 24",
- (rtl::Uri::decode(
+ ASSERT_TRUE((rtl::Uri::decode(
aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 24";
}
{
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%81 "));
aText2 = rtl::OUString();
- CPPUNIT_ASSERT_MESSAGE(
- "failure 25",
- (rtl::Uri::decode(
+ ASSERT_TRUE((rtl::Uri::decode(
aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)
- == aText2));
+ == aText2)) <<
+ "failure 25";
}
{
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%81%20"));
aText2 = rtl::OUString();
- CPPUNIT_ASSERT_MESSAGE(
- "failure 26",
- (rtl::Uri::decode(
+ ASSERT_TRUE((rtl::Uri::decode(
aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)
- == aText2));
+ == aText2)) <<
+ "failure 26";
}
{
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%81%30%B1%33"));
sal_Unicode const aText2U[] = { 0x028A, 0 };
aText2 = rtl::OUString(aText2U);
- CPPUNIT_ASSERT_MESSAGE(
- "failure 27",
- (rtl::Uri::decode(
+ ASSERT_TRUE((rtl::Uri::decode(
aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)
- == aText2));
+ == aText2)) <<
+ "failure 27";
}
{
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%810%B13"));
sal_Unicode const aText2U[] = { 0x028A, 0 };
aText2 = rtl::OUString(aText2U);
- CPPUNIT_ASSERT_MESSAGE(
- "failure 28",
- (rtl::Uri::decode(
+ ASSERT_TRUE((rtl::Uri::decode(
aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)
- == aText2));
+ == aText2)) <<
+ "failure 28";
}
// Check rtl_UriEncodeStrictKeepEscapes mode:
@@ -504,38 +468,38 @@ void Test::test_Uri() {
{
aText1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%%ea%c3%aa"));
aText2 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%25%EA%C3%AA"));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 29",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeStrictKeepEscapes,
RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 29";
}
{
sal_Unicode const aText1U[] = { 0x00EA, 0 };
aText1 = rtl::OUString(aText1U);
aText2 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%C3%AA"));
- CPPUNIT_ASSERT_MESSAGE(
- "failure 30",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeStrictKeepEscapes,
RTL_TEXTENCODING_UTF8)
- == aText2));
+ == aText2)) <<
+ "failure 30";
}
{
sal_Unicode const aText1U[] = { ' ', '!', 0x0401, 0x0700, 0x045F, 0 };
aText1 = rtl::OUString(aText1U);
aText2 = rtl::OUString();
- CPPUNIT_ASSERT_MESSAGE(
- "failure 23",
- (rtl::Uri::encode(
+ ASSERT_TRUE((rtl::Uri::encode(
aText1, rtl_UriCharClassUric, rtl_UriEncodeStrictKeepEscapes,
RTL_TEXTENCODING_ISO_8859_5)
- == aText2));
+ == aText2)) <<
+ "failure 23";
}
}
}
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "rtl_testuri");
-NOADDITIONAL;
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
More information about the Libreoffice-commits
mailing list