Kaydet (Commit) 2e963d05 authored tarafından David Ostrovsky's avatar David Ostrovsky Kaydeden (comit) Noel Power

Delete unused sal tests

Change-Id: Iba1eeb8d8fd0582f216b7552dc9ae21b69e66b4e
Reviewed-on: https://gerrit.libreoffice.org/4326Reviewed-by: 's avatarNoel Power <noel.power@suse.com>
Tested-by: 's avatarNoel Power <noel.power@suse.com>
üst 0d5a2d22
This is the old test implemantation of rtl::XString.
If you want to write new or better tests:
Identify the test function in the source and remark it.
The best way to remark old tests, go to the end of the source code and remark
only the test_rtl_<X>String_<function>(hRtlTestResult); so the test will not
executed any longer.
There are already some new tests for rtl::XString, take a look into the
directory sal/qa/rtl/ostring or sal/qa/rtl/oustring, where are some
replacements added.
Any other Questions?
Do not hesitate to contact me at 'lla<at>openoffice.org'.
best regards,
Lars
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <math.h>
#include <stdlib.h>
#include <sal/types.h>
#include <rtl/ustring.h>
#include <rtl/string.hxx>
#include <rtl_String_Utils_Const.h>
using ::rtl::OString;
sal_uInt32 AStringLen( const sal_Char *pAStr )
{
sal_uInt32 nStrLen = 0;
if ( pAStr != NULL )
{
const sal_Char *pTempStr = pAStr;
while( *pTempStr )
{
pTempStr++;
} // while
nStrLen = (sal_uInt32)( pTempStr - pAStr );
} // if
return nStrLen;
} // AStringLen
sal_Char* cpystr( sal_Char* dst, const sal_Char* src )
{
const sal_Char* psrc = src;
sal_Char* pdst = dst;
while( *pdst++ = *psrc++ );
return ( dst );
}
sal_Char* cpynstr( sal_Char* dst, const sal_Char* src, sal_uInt32 cnt )
{
const sal_Char* psrc = src;
sal_Char* pdst = dst;
sal_uInt32 len = cnt;
sal_uInt32 i;
if ( len >= AStringLen(src) )
{
return( cpystr( dst, src ) );
}
// copy string by char
for( i = 0; i < len; i++ )
*pdst++ = *psrc++;
*pdst = '\0';
return ( dst );
}
//------------------------------------------------------------------------
sal_Bool cmpstr( const sal_Char* str1, const sal_Char* str2, sal_uInt32 len )
{
const sal_Char* pBuf1 = str1;
const sal_Char* pBuf2 = str2;
sal_uInt32 i = 0;
while ( (*pBuf1 == *pBuf2) && i < len )
{
(pBuf1)++;
(pBuf2)++;
i++;
}
return( i == len );
}
//------------------------------------------------------------------------
sal_Bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2, sal_uInt32 len )
{
const sal_Unicode* pBuf1 = str1;
const sal_Unicode* pBuf2 = str2;
sal_uInt32 i = 0;
while ( (*pBuf1 == *pBuf2) && i < len )
{
(pBuf1)++;
(pBuf2)++;
i++;
}
return( i == len );
}
//-----------------------------------------------------------------------
sal_Bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2 )
{
const sal_Unicode* pBuf1 = str1;
const sal_Unicode* pBuf2 = str2;
sal_Bool res = sal_True;
while ( (*pBuf1 == *pBuf2) && *pBuf1 !='\0' && *pBuf2 != '\0')
{
(pBuf1)++;
(pBuf2)++;
}
if (*pBuf1 == '\0' && *pBuf2 == '\0')
res = sal_True;
else
res = sal_False;
return (res);
}
sal_Char* createName( sal_Char* dst, const sal_Char* meth, sal_uInt32 cnt )
{
sal_Char* pdst = dst;
sal_Char nstr[16];
sal_Char* pstr = nstr;
rtl_str_valueOfInt32( pstr, cnt, 10 );
cpystr( pdst, meth );
cpystr( pdst+ AStringLen(meth), "_" );
if ( cnt < 100 )
{
cpystr(pdst + AStringLen(pdst), "0" );
}
if ( cnt < 10 )
{
cpystr(pdst + AStringLen(pdst), "0" );
}
cpystr( pdst + AStringLen(pdst), nstr );
return( pdst );
}
//------------------------------------------------------------------------
static inline sal_Int32 ACharToUCharCompare( const sal_Unicode *pUStr,
const sal_Char *pAStr
)
{
sal_Int32 nCmp = 0;
sal_Int32 nUChar = (sal_Int32)*pUStr;
sal_Int32 nChar = (sal_Int32)((unsigned char)*pAStr);
nCmp = nUChar - nChar;
return nCmp;
} // ACharToUCharCompare
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _RTL_STRING_UTILS_HXX_
#define _RTL_STRING_UTILS_HXX_
#ifdef __cplusplus
#include <math.h>
#include <stdlib.h>
#include <sal/types.h>
#include <rtl/ustring.h>
#include <rtl/string.hxx>
sal_Char* cpystr( sal_Char* dst, const sal_Char* src );
sal_Char* cpynstr( sal_Char* dst, const sal_Char* src, sal_uInt32 cnt );
sal_Bool cmpstr( const sal_Char* str1, const sal_Char* str2, sal_uInt32 len );
sal_Bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2, sal_uInt32 len );
sal_Bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2 );
sal_Char* createName( sal_Char* dst, const sal_Char* src, sal_uInt32 cnt );
sal_uInt32 AStringLen( const sal_Char *pAStr );
//------------------------------------------------------------------------
sal_Bool AStringNIsValid( const sal_Char *pAStr,
const sal_uInt32 nStrLen
);
//------------------------------------------------------------------------
sal_Int32 AStringToUStringCompare( const sal_Unicode *pUStr,
const sal_Char *pAStr
);
sal_Int32 AStringToUStringNCompare( const sal_Unicode *pUStr,
const sal_Char *pAStr,
const sal_uInt32 nAStrCount
);
#endif /* __cplusplus */
#endif /* _RTL_STRING_UTILS_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _RTL_STRING_UTILS_CONST_H_
#define _RTL_STRING_UTILS_CONST_H_
#include <sal/types.h>
#ifdef __cplusplus
extern "C"
{
#endif
static const sal_Int32 kErrCompareAStringToUString = -2;
static const sal_Int32 kErrCompareNAStringToUString = -3;
static const sal_Int32 kErrCompareAStringToRTLUString = -4;
static const sal_Int32 kErrCompareNAStringToRTLUString = -5;
static const sal_Int32 kErrAStringToByteStringCompare = -6;
static const sal_Int32 kErrAStringToByteStringNCompare = -7;
static const sal_Int32 kErrCompareAStringToString = -8;
static const sal_Int32 kErrCompareNAStringToString = -9;
#ifdef __cplusplus
}
#endif
#endif /* _RTL_STRING_UTILS_CONST_H_ */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// LLA:
// this file is converted to use with testshl2
// original was placed in sal/test/textenc.cxx
#include <string.h>
#include <stdio.h>
#include <rtl/string.hxx>
#include <testshl/simpleheader.hxx>
#define TEST_ENSURE(c, m) CPPUNIT_ASSERT_MESSAGE((m), (c))
using ::rtl::OString;
namespace rtl_OString
{
class oldtests : public CppUnit::TestFixture
{
public:
void test_OString();
CPPUNIT_TEST_SUITE( oldtests );
CPPUNIT_TEST( test_OString );
CPPUNIT_TEST_SUITE_END( );
};
#ifdef WNT
#pragma warning( disable : 4723 )
#endif
void oldtests::test_OString()
{
TEST_ENSURE( sal_True, "_USENAMEPSACE defined");
// "Mein erster RTL OString\n"
// | | | | |
// Index 0 5 10 15 20
OString s1("Mein erster RTL OString\n");
TEST_ENSURE( s1 == "Mein erster RTL OString\n", "test_OString error 1");
TEST_ENSURE( s1.getLength() == 24, "test_OString error 2");
OString s2 = s1;
TEST_ENSURE( s2[16] == 'O', "test_OString error 3");
TEST_ENSURE( s2.equals(s1), "test_OString error 4");
TEST_ENSURE( s2.indexOf('O') == 16, "test_OString error 5");
TEST_ENSURE( s2.indexOf('O', 5) == 16, "test_OString error 5a");
TEST_ENSURE( s2.lastIndexOf('r') == 19, "test_OString error 6");
TEST_ENSURE( s2[19] == 'r', "test_OString error 7");
TEST_ENSURE( s2[23] == '\n', "test_OString error 8");
TEST_ENSURE( s2.lastIndexOf('\n') == 23, "test_OString error 9");
TEST_ENSURE( s2.lastIndexOf('M') == 0, "test_OString error 10");
TEST_ENSURE( s2.lastIndexOf('t', s2.getLength() - 8) == 8, "test_OString error 9");
// "Mein erster RTL OString ist ein String aus der RTL Library\n"
// | | | | | | | | | | | |
// Index 0 5 10 15 20 25 30 35 40 45 50 55
OString s3 = s2.copy(0, s2.getLength() - 1);
OString s4 = s3.concat(" ist ein String aus der RTL Library\n");
TEST_ENSURE( s4.getLength() == 59, "test_OString error 11");
s1 = s4.copy(0, 38);
OString s5;
s5 = s1 + " aus der RTL Library\n";
TEST_ENSURE( s5.compareTo(s4) == 0 , "test_OString error 12");
TEST_ENSURE( s5.indexOf("RTL") == 12, "test_OString error 13");
TEST_ENSURE( s5.lastIndexOf("RTL") == 47, "test_OString error 13");
sal_Bool b = sal_False;
OString s6 = s5.valueOf(b);
TEST_ENSURE( s6.compareTo("false") == 0, "test_OString error 14");
s6 = s5.valueOf('H');
TEST_ENSURE( s6.compareTo("H") == 0, "test_OString error 15");
sal_Int32 n = 123456789L;
s6 = s5.valueOf(n);
TEST_ENSURE( s6.compareTo("123456789") == 0, "test_OString error 16");
#ifdef SAL_UNX
sal_Int64 m = -3223372036854775807LL;
#else
sal_Int64 m = -3223372036854775807;
#endif
s6 = s5.valueOf(m);
TEST_ENSURE( s6.compareTo("-3223372036854775807") == 0, "test_OString error 17");
OString s7("HaLLo");
s7 = s7.toAsciiLowerCase();
TEST_ENSURE( s7 == "hallo", "test_OString error 19");
s7 = s7.toAsciiUpperCase();
TEST_ENSURE( s7 == "HALLO", "test_OString error 20");
OString s8("HaLLo ICH BIn eIn StRiNg");
s7 = s8.toAsciiLowerCase();
TEST_ENSURE( s8.equalsIgnoreAsciiCase(s7), "test_OString error 21");
s8 = s7.toAsciiUpperCase();
TEST_ENSURE( s8 == "HALLO ICH BIN EIN STRING", "test_OString error 22");
s7 = " ";
s8 = s7 + s8 + " ";
TEST_ENSURE( s8 == " HALLO ICH BIN EIN STRING ",
"test_OString error 23");
s7 = s8.trim();
TEST_ENSURE( s7 == "HALLO ICH BIN EIN STRING", "test_OString error 24");
TEST_ENSURE( strcmp(s7.getStr(), "HALLO ICH BIN EIN STRING") == 0,
"test_OString error 25");
s7 = "Hallo";
s8 = "aber Hallo";
TEST_ENSURE( s7 < s8, "test_OString error 26");
TEST_ENSURE( s8 > s7, "test_OString error 27");
TEST_ENSURE( s7 != s8, "test_OString error 28");
TEST_ENSURE( s7 != "blabla", "test_OString error 29");
TEST_ENSURE( "blabla" != s7, "test_OString error 30");
s8 = "Hallo";
TEST_ENSURE( s7 <= s8, "test_OString error 31");
TEST_ENSURE( s7 >= s8, "test_OString error 32");
s8 = s8.replace('l', 'r');
TEST_ENSURE( s8 == "Harro", "test_OString error 33");
sal_Int32 nIndex = 0;
s8 = "|hallo1|hallo2|hallo3|hallo4|hallo5|hallo6|hallo7|hallo8|";
TEST_ENSURE( s8.getToken(3,'|', nIndex) == "hallo3", "test_OString error 40");
char* Tokens[10] = { "", "hallo1", "hallo2", "hallo3", "hallo4",
"hallo5", "hallo6", "hallo7", "hallo8", "" };
nIndex = 0;
sal_Int32 i = 0;
do
{
TEST_ENSURE( s8.getToken(0,'|',nIndex) == Tokens[i], "test_OString error 40e");
i++;
}
while ( nIndex >= 0 );
s7 = "";
s7 += s8;
TEST_ENSURE( s7 == s8, "test_OString error 41");
s7 = s8.replaceAt(8, 6, "mmmmmmmmmm");
TEST_ENSURE( s7.getLength() == 61, "test_OString error 42");
s8 = s7.replaceAt(8, 11, "");
TEST_ENSURE( s8.getLength() == 50, "test_OString error 43");
s7 = s8.replaceAt(8, 0, "hallo2|");
TEST_ENSURE( s7.getLength() == 57, "test_OString error 44");
sal_Int32 pos = 0;
while ((pos = s7.indexOf("|")) >= 0)
{
s8 = s7.replaceAt(pos, 1, "**");
s7 = s8;
}
TEST_ENSURE( s7.getLength() == 66, "test_OString error 45");
TEST_ENSURE( OString( "aaa" ).compareTo( OString( "bbb" ) ) < 0, "test_OString error 46" );
TEST_ENSURE( OString( "aaa" ).compareTo( OString( "aaa" ) ) == 0, "test_OString error 47" );
TEST_ENSURE( OString( "bbb" ).compareTo( OString( "aaa" ) ) > 0, "test_OString error 48" );
TEST_ENSURE( OString( "aaaa" ).compareTo( OString( "bbb" ) ) < 0, "test_OString error 49" );
TEST_ENSURE( OString( "aaa" ).compareTo( OString( "bbbb" ) ) < 0, "test_OString error 50" );
TEST_ENSURE( OString( "aaa" ).compareTo( OString( "aaaa" ) ) < 0, "test_OString error 51" );
TEST_ENSURE( OString( "aaaa" ).compareTo( OString( "aaa" ) ) > 0, "test_OString error 52" );
TEST_ENSURE( OString( "bbbb" ).compareTo( OString( "bbb" ) ) > 0, "test_OString error 53" );
TEST_ENSURE( OString( "bbb" ) == OString( "bbb" ), "test_OString error 54" );
TEST_ENSURE( OString( "bbb" ) == "bbb", "test_OString error 55" );
/*
* As clarified in #104229#, calling copy with invalid arguments causes
* undefined behaviour, so the following test does no longer work:
s7 = "Hallo jetzt komm ich";
s8 = s7.copy(0, s7.indexOf(':'));
TEST_ENSURE( s8.getLength() == 0, "test_OString error 56");
TEST_ENSURE( s8.compareTo("") == 0, "test_OString error 57");
*/
double f = OString("1.7e-10").toDouble();
TEST_ENSURE(f > 1E-10 && f < 2E-10, "1.7e-10 problem");
f = OString("1.7e+10").toDouble();
TEST_ENSURE(f > 1E10 && f < 2E10, "1.7e+10 problem");
f = OString("1.7e10").toDouble();
TEST_ENSURE(f > 1E10 && f < 2E10, "1.7e308 problem");
{
float f0 = 0;
float f1 = 1;
float fInf = f1 / f0;
OString aStr1(OString::valueOf(fInf));
OString aStr2("1.#INF");
bool bSuccess = aStr1 == aStr2;
if (!bSuccess)
printf("ERROR: OString::valueOf(1f/0f): %s\n", aStr1.getStr());
TEST_ENSURE(bSuccess, "OString::valueOf(1f/0f)");
}
printf("test_OString OK !!!\n");
return;
}
} // namespace rtl_OString
// -----------------------------------------------------------------------------
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( rtl_OString::oldtests, "rtl_OString" );
// -----------------------------------------------------------------------------
NOADDITIONAL;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// LLA:
// this file is converted to use with testshl2
// original was placed in sal/test/textenc.cxx
#include <string.h>
#include <stdio.h>
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
#include <testshl/simpleheader.hxx>
using ::rtl::OUString;
using ::rtl::OString;
using ::rtl::OUStringBuffer;
using ::rtl::OStringBuffer;
#define TEST_ENSURE(c, m) CPPUNIT_ASSERT_MESSAGE((m), (c))
namespace rtl_OStringBuffer
{
class oldtests : public CppUnit::TestFixture
{
public:
void test_OStringBuffer();
CPPUNIT_TEST_SUITE( oldtests );
CPPUNIT_TEST( test_OStringBuffer );
CPPUNIT_TEST_SUITE_END( );
};
void oldtests::test_OStringBuffer()
{
// "Mein erster RTL OString\n"
// | | | | |
// Index 0 5 10 15 20
OString s1("Mein erster RTL OString\n");
OStringBuffer b1(s1);
TEST_ENSURE( b1.getCapacity() == 16 + s1.getLength(), "test_OStringBuffer error 1");
b1.insert(b1.getLength() - 1, "Buffer");
s1 = "Mein erster RTL OStringBuffer\n";
TEST_ENSURE( s1 == b1.getStr(), "test_OStringBuffer error 2");
b1.insert(b1.getLength() - 1, " ist viel zu gross fuer den alten Buffer");
TEST_ENSURE( b1.getCapacity() == b1.getLength(), "test_OStringBuffer error 3");
OStringBuffer b2(30);
s1 = "false";
sal_Bool b = sal_False;
b2.append(b);
TEST_ENSURE( s1 == b2.getStr(), "test_OStringBuffer error 4");
sal_Int32 n = 123456789L;
s1 += " 123456789";
b2.append(" ");
b2.append(n);
TEST_ENSURE( s1 == b2.getStr(), "test_OStringBuffer error 5");
#ifdef SAL_UNX
sal_Int64 m = -3223372036854775807LL;
#else
sal_Int64 m = -3223372036854775807;
#endif
s1 += " -3223372036854775807";
b2.append(" ");
b2.append(m);
TEST_ENSURE( s1 == b2.getStr(), "test_OStringBuffer error 6");
OString s2(b2.makeStringAndClear());
TEST_ENSURE( s1 == s2, "test_OStringBuffer error 7");
b2.ensureCapacity(50);
TEST_ENSURE( b2.getCapacity() == 50, "test_OStringBuffer error 8");
b2.append("Hier fuege ich jetzt ein > <\n");
b2.insert(26, " Hallo");
s2 = "Hier fuege ich jetzt ein > Hallo <\n";
TEST_ENSURE( s2 == b2.getStr(), "test_OStringBuffer error 9");
b2.insert(26, b);
b2.insert(26, " ");
s2 = "Hier fuege ich jetzt ein > false Hallo <\n";
TEST_ENSURE( s2 == b2.getStr(), "test_OStringBuffer error 10");
b2.insert(26, n);
b2.insert(26, " ");
s2 = "Hier fuege ich jetzt ein > 123456789 false Hallo <\n";
TEST_ENSURE( s2 == b2.getStr(), "test_OStringBuffer error 11");
b2.insert(26, m);
b2.insert(26, " ");
s2 = "Hier fuege ich jetzt ein > -3223372036854775807 123456789 false Hallo <\n";
TEST_ENSURE( s2 == b2.getStr(), "test_OStringBuffer error 12");
printf("test_OStringBuffer OK !!!\n");
return;
}
} // namespace rtl_OStringBuffer
// -----------------------------------------------------------------------------
namespace rtl_OUStringBuffer
{
class oldtests : public CppUnit::TestFixture
{
public:
void test_OUStringBuffer();
CPPUNIT_TEST_SUITE( oldtests );
CPPUNIT_TEST( test_OUStringBuffer );
CPPUNIT_TEST_SUITE_END( );
};
void oldtests::test_OUStringBuffer()
{
// "Mein erster RTL OUString\n"
// | | | | |
// Index 0 5 10 15 20
OUString s1(OUString("Mein erster RTL OUString\n"));
OUStringBuffer b1(s1);
TEST_ENSURE( b1.getCapacity() == 16 + s1.getLength(), "test_OWStringBuffer error 1");
b1.insert(b1.getLength() - 1, OUString("Buffer"));
s1 = OUString("Mein erster RTL OUStringBuffer\n");
TEST_ENSURE( s1 == b1.getStr(), "test_OWStringBuffer error 2");
b1.insert(b1.getLength() - 1, OUString(" ist viel zu gross fuer den alten Buffer"));
//TEST_ENSURE( b1.getCapacity() == b1.getLength(), "test_OWStringBuffer error 3");
OUStringBuffer b2(30);
s1 = OUString("false");
sal_Bool b = sal_False;
b2.append(b);
TEST_ENSURE( s1 == b2.getStr(), "test_OWStringBuffer error 4");
sal_Int32 n = 123456789L;
s1 += " 123456789";
b2.append(OUString(" "));
b2.append(n);
TEST_ENSURE( s1 == b2.getStr(), "test_OWStringBuffer error 5");
#ifdef SAL_UNX
sal_Int64 m = -3223372036854775807LL;
#else
sal_Int64 m = -3223372036854775807;
#endif
s1 += " -3223372036854775807";
b2.append(OUString(" "));
b2.append(m);
TEST_ENSURE( s1 == b2.getStr(), "test_OWStringBuffer error 6");
OUString s2(b2.makeStringAndClear());
TEST_ENSURE( s1 == s2, "test_OWStringBuffer error 7");
b2.ensureCapacity(50);
TEST_ENSURE( b2.getCapacity() == 50, "test_OWStringBuffer error 8");
b2.append(OUString("Hier fuege ich jetzt ein > <\n"));
b2.insert(26, OUString(" Hallo"));
s2 = OUString("Hier fuege ich jetzt ein > Hallo <\n");
TEST_ENSURE( s2 == b2.getStr(), "test_OWStringBuffer error 9");
b2.insert(26, b);
b2.insert(26, OUString(" "));
s2 = OUString("Hier fuege ich jetzt ein > false Hallo <\n");
TEST_ENSURE( s2 == b2.getStr(), "test_OWStringBuffer error 10");
b2.insert(26, n);
b2.insert(26, OUString(" "));
s2 = OUString("Hier fuege ich jetzt ein > 123456789 false Hallo <\n");
TEST_ENSURE( s2 == b2.getStr(), "test_OWStringBuffer error 11");
b2.insert(26, m);
b2.insert(26, OUString(" "));
s2 = OUString("Hier fuege ich jetzt ein > -3223372036854775807 123456789 false Hallo <\n");
TEST_ENSURE( s2 == b2.getStr(), "test_OWStringBuffer error 12");
// ASCII-Schnittstelle, AB 15.10.1999
OUString s3(OUString("Noch'n RTL OUString"));
OUStringBuffer b3(s3);
sal_Char aAsciiStr[] = " mit appendetem ASCII\n";
b3.appendAscii( aAsciiStr );
s3 = OUString("Noch'n RTL OUString mit appendetem ASCII\n");
TEST_ENSURE( b3.getStr() == s3 , "test_OWStringBuffer error 13");
printf("test_OWStringBuffer OK !!!\n");
return;
}
} // namespace rtl_OUStringBuffer
// -----------------------------------------------------------------------------
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( rtl_OUStringBuffer::oldtests, "rtl_OUStringBuffer" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( rtl_OStringBuffer::oldtests, "rtl_OStringBuffer" );
// -----------------------------------------------------------------------------
NOADDITIONAL;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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