summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Le Ray <sebastien-libreoffice@orniz.org>2011-02-12 14:48:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-02-14 21:15:40 +0000
commit7dd2d4a0f50cf7fc4e6d509ff8a21d4fe3c3a42a (patch)
tree887d874bc709689c29d7a18b06be1dd9e6fe1f99
parentAdded toString() method to O(U)StringBuffer. (diff)
downloadcore-7dd2d4a0f50cf7fc4e6d509ff8a21d4fe3c3a42a.tar.gz
core-7dd2d4a0f50cf7fc4e6d509ff8a21d4fe3c3a42a.zip
Unit test cleanup for OUStringBuffer.
Moved OUStringBuffer related tests from qa/srt/strings to qa/rt/oustringbuffer and reactivated it in project build. It seems that rtl_OUStringBuffer2.cxx was replaced by test_oustringbuffer_utf32.cxx so the later has been removed. Added unit tests for toString.
-rw-r--r--sal/prj/build.lst1
-rw-r--r--sal/qa/rtl/oustringbuffer/makefile.mk49
-rw-r--r--sal/qa/rtl/oustringbuffer/rtl_OUStringBuffer2.cxx103
-rw-r--r--sal/qa/rtl/oustringbuffer/test_oustringbuffer_noadditional.cxx36
-rw-r--r--sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx64
-rw-r--r--sal/qa/rtl/oustringbuffer/test_oustringbuffer_utf32.cxx (renamed from sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx)0
-rw-r--r--sal/qa/rtl/strings/makefile.mk1
7 files changed, 118 insertions, 136 deletions
diff --git a/sal/prj/build.lst b/sal/prj/build.lst
index 0d53b825f93a..1b38581385f7 100644
--- a/sal/prj/build.lst
+++ b/sal/prj/build.lst
@@ -22,3 +22,4 @@ sa sal\qa\osl\file nmake - u sa_qa_osl_file sa_cppunittester sa_util NULL
sa sal\qa\osl\module nmake - u sa_qa_osl_module sa_cppunittester sa_util NULL
sa sal\qa\osl\condition nmake - all sa_qa_osl_condition sa_cppunittester sa_util NULL
sa sal\qa\rtl\strings nmake - all sa_qa_rt_strings sa_cppunittester sa_util NULL
+sa sal\qa\rtl\oustringbuffer nmake - all sa_qa_rt_oustringbuffer sa_cppunittester sa_util NULL
diff --git a/sal/qa/rtl/oustringbuffer/makefile.mk b/sal/qa/rtl/oustringbuffer/makefile.mk
index 544f7b7df170..9165daa11350 100644
--- a/sal/qa/rtl/oustringbuffer/makefile.mk
+++ b/sal/qa/rtl/oustringbuffer/makefile.mk
@@ -25,46 +25,31 @@
#
#*************************************************************************
-PRJ=..$/..$/..
-INCPRE+= $(PRJ)$/qa$/inc
+PRJ := ..$/..$/..
+PRJNAME := sal
-PRJNAME=sal
-TARGET=rtl_oustringbuffer2
+TARGET := qa_rtl_oustringbuffer
-ENABLE_EXCEPTIONS=TRUE
+ENABLE_EXCEPTIONS := TRUE
-# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
-.INCLUDE : settings.mk
CFLAGS+= $(LFS_CFLAGS)
CXXFLAGS+= $(LFS_CFLAGS)
CFLAGSCXX += $(CPPUNIT_CFLAGS)
-# BEGIN ----------------------------------------------------------------
-# auto generated Target:joblist by codegen.pl
-SHL1OBJS= \
- $(SLO)$/rtl_OUStringBuffer2.obj
-
-SHL1TARGET= rtl_OUStringBuffer2
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-
-SHL1IMPLIB= i$(SHL1TARGET)
-# SHL1DEF= $(MISC)$/$(SHL1TARGET).def
-
-DEF1NAME =$(SHL1TARGET)
-# DEF1EXPORTFILE= export.exp
-SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
-# auto generated Target:joblist
-# END ------------------------------------------------------------------
-
-#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
+SHL1TARGET := $(TARGET)
+SHL1OBJS := \
+ $(SLO)$/test_oustringbuffer_utf32.obj \
+ $(SLO)$/test_oustringbuffer_tostring.obj \
+ $(SLO)$/test_oustringbuffer_noadditional.obj
+SHL1IMPLIB := i$(SHL1TARGET)
+SHL1STDLIBS := $(SALLIB) $(CPPUNITLIB)
+SHL1VERSIONMAP := $(PRJ)$/qa$/export.map
+DEF1NAME := $(SHL1TARGET)
+
+.INCLUDE: target.mk
+.INCLUDE: $(PRJ)$/qa$/cppunit_local.mk
diff --git a/sal/qa/rtl/oustringbuffer/rtl_OUStringBuffer2.cxx b/sal/qa/rtl/oustringbuffer/rtl_OUStringBuffer2.cxx
deleted file mode 100644
index 942bf212eed2..000000000000
--- a/sal/qa/rtl/oustringbuffer/rtl_OUStringBuffer2.cxx
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sal.hxx"
-#include <testshl/simpleheader.hxx>
-#include "stringhelper.hxx"
-#include <rtl/ustrbuf.hxx>
-#include <rtl/uri.hxx>
-
-namespace rtl_OUStringBuffer
-{
-
-
-class insertUtf32 : public CppUnit::TestFixture
-{
-public:
- // initialise your test code values here.
- void setUp()
- {
- }
-
- void tearDown()
- {
- }
-
- void insertUtf32_001()
- {
- ::rtl::OUStringBuffer aUStrBuf(4);
- aUStrBuf.insertUtf32(0,0x10ffff);
-
- rtl::OUString suStr = aUStrBuf.makeStringAndClear();
- rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
-
- rtl::OString sStr;
- sStr <<= suStr2;
- t_print("%s\n", sStr.getStr());
-
- CPPUNIT_ASSERT_MESSAGE("Strings must be '%F4%8F%BF%BF'", sStr.equals(rtl::OString("%F4%8F%BF%BF")) == sal_True);
- }
-
- void insertUtf32_002()
- {
- ::rtl::OUStringBuffer aUStrBuf(4);
- aUStrBuf.insertUtf32(0,0x41);
- aUStrBuf.insertUtf32(1,0x42);
- aUStrBuf.insertUtf32(2,0x43);
-
- rtl::OUString suStr = aUStrBuf.makeStringAndClear();
- rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
-
- rtl::OString sStr;
- sStr <<= suStr2;
- t_print("%s\n", sStr.getStr());
-
- CPPUNIT_ASSERT_MESSAGE("Strings must be 'ABC'", sStr.equals(rtl::OString("ABC")) == sal_True);
- }
-
- CPPUNIT_TEST_SUITE(insertUtf32);
- CPPUNIT_TEST(insertUtf32_001);
- CPPUNIT_TEST(insertUtf32_002);
- CPPUNIT_TEST_SUITE_END();
-}; // class getToken
-
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUStringBuffer::insertUtf32, "rtl_OUStringBuffer");
-
-} // namespace rtl_OUStringBuffer
-
-
-// -----------------------------------------------------------------------------
-
-// this macro creates an empty function, which will called by the RegisterAllFunctions()
-// to let the user the possibility to also register some functions by hand.
-NOADDITIONAL;
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_noadditional.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_noadditional.cxx
new file mode 100644
index 000000000000..18e8a634460b
--- /dev/null
+++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_noadditional.cxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#include <cppunit/plugin/TestPlugIn.h>
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx
new file mode 100644
index 000000000000..31aecac810db
--- /dev/null
+++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/TestAssert.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include "rtl/ustrbuf.hxx"
+#include "rtl/ustring.hxx"
+
+namespace test { namespace oustringbuffer {
+
+class ToString: public CppUnit::TestFixture {
+private:
+ void testToString();
+
+ CPPUNIT_TEST_SUITE(ToString);
+ CPPUNIT_TEST(testToString);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+} }
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test::oustringbuffer::ToString);
+
+void test::oustringbuffer::ToString::testToString() {
+ rtl::OUStringBuffer sb(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test string")));
+ rtl::OUString str = sb.toString();
+ CPPUNIT_ASSERT(str.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("test string")));
+ // returned OUString must be independent from sb
+ sb.append('a');
+ CPPUNIT_ASSERT(str.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("test string")));
+ sb.setLength(0);
+ CPPUNIT_ASSERT(str.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("test string")));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_utf32.cxx
index 13e75a476adf..13e75a476adf 100644
--- a/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx
+++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_utf32.cxx
diff --git a/sal/qa/rtl/strings/makefile.mk b/sal/qa/rtl/strings/makefile.mk
index d167c470df3d..2b07539e8683 100644
--- a/sal/qa/rtl/strings/makefile.mk
+++ b/sal/qa/rtl/strings/makefile.mk
@@ -42,7 +42,6 @@ CFLAGSCXX += $(CPPUNIT_CFLAGS)
SHL1TARGET := $(TARGET)
SHL1OBJS := \
- $(SLO)$/test_oustringbuffer_utf32.obj \
$(SLO)$/test_oustring_compare.obj \
$(SLO)$/test_oustring_convert.obj \
$(SLO)$/test_oustring_endswith.obj \