diff options
author | Theo van Klaveren <theo.van.klaveren@gmail.com> | 2011-03-17 14:35:53 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-03-18 09:35:53 +0000 |
commit | 38e7eb013ae25f9ae67f5eb153f8eb29b85d6a55 (patch) | |
tree | ff5c23474cccde5ab58eea94afd9760858bf78e6 /sal | |
parent | a5920326e20ae8148841f65a400ab47b897a3884 (diff) |
Make the qa/rtl/rtl_ostring test compile again.
These crash on NULL pointers, which they expect the API to handle properly.
It doesn't.
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/rtl/ostring/rtl_OString2.cxx | 29 | ||||
-rw-r--r-- | sal/qa/rtl/ostring/rtl_str.cxx | 48 | ||||
-rw-r--r-- | sal/qa/rtl/ostring/rtl_string.cxx | 16 |
3 files changed, 55 insertions, 38 deletions
diff --git a/sal/qa/rtl/ostring/rtl_OString2.cxx b/sal/qa/rtl/ostring/rtl_OString2.cxx index 1c28b36be5ab..a4a50d8ca880 100644 --- a/sal/qa/rtl/ostring/rtl_OString2.cxx +++ b/sal/qa/rtl/ostring/rtl_OString2.cxx @@ -32,7 +32,12 @@ // autogenerated file with codegen.pl // There exist some more test code in sal/qa/rtl_strings/rtl_OString.cxx -#include <testshl/simpleheader.hxx> +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <rtl/string.hxx> + #include "valueequal.hxx" namespace rtl_OString @@ -44,7 +49,7 @@ class valueOf : public CppUnit::TestFixture { rtl::OString sValue; sValue = rtl::OString::valueOf( _nValue ); - t_print(T_VERBOSE, "nFloat := %.9f sValue := %s\n", _nValue, sValue.getStr()); + printf("nFloat := %.9f sValue := %s\n", _nValue, sValue.getStr()); float nValueATOF = static_cast<float>(atof( sValue.getStr() )); @@ -122,7 +127,7 @@ private: { rtl::OString sValue; sValue = rtl::OString::valueOf( _nValue ); - t_print(T_VERBOSE, "nDouble := %.20f sValue := %s\n", _nValue, sValue.getStr()); + printf("nDouble := %.20f sValue := %s\n", _nValue, sValue.getStr()); double nValueATOF = atof( sValue.getStr() ); @@ -255,7 +260,7 @@ public: // insert your test code here. void toDouble_selftest() { - t_print("Start selftest:\n"); + printf("Start selftest:\n"); CPPUNIT_ASSERT (is_double_equal(1.0, 1.01) == false); CPPUNIT_ASSERT (is_double_equal(1.0, 1.001) == false); CPPUNIT_ASSERT (is_double_equal(1.0, 1.0001) == false); @@ -272,7 +277,7 @@ public: CPPUNIT_ASSERT (is_double_equal(1.0, 1.00000000000001) == true); CPPUNIT_ASSERT (is_double_equal(1.0, 1.000000000000001) == true); CPPUNIT_ASSERT (is_double_equal(1.0, 1.0000000000000001) == true); - t_print("Selftest done.\n"); + printf("Selftest done.\n"); } void toDouble_test_3() @@ -389,7 +394,7 @@ public: rtl::OString sToken = sTokenStr.getToken( 0, ';', nIndex ); } while ( nIndex >= 0 ); - // t_print("Index %d\n", nIndex); + // printf("Index %d\n", nIndex); // should not GPF } @@ -498,7 +503,7 @@ public: ::rtl::OString aStr1; aStr1= input->replaceAt( index, count, *newStr ); - t_print("the result OString is %s#\n", aStr1.getStr() ); + printf("the result OString is %s#\n", aStr1.getStr() ); sal_Bool bRes = ( expVal->compareTo(aStr1) == 0 ); return bRes; @@ -553,10 +558,10 @@ public: // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OString::valueOf, "rtl_OString"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OString::toDouble, "rtl_OString"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OString::getToken, "rtl_OString"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OString::replaceAt, "rtl_OString"); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_OString::valueOf); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_OString::toDouble); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_OString::getToken); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_OString::replaceAt); } // namespace rtl_OString @@ -565,6 +570,6 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OString::replaceAt, "rtl_OString"); // 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; +CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/rtl/ostring/rtl_str.cxx b/sal/qa/rtl/ostring/rtl_str.cxx index c3408d5b8eb5..b04a49d8b500 100644 --- a/sal/qa/rtl/ostring/rtl_str.cxx +++ b/sal/qa/rtl/ostring/rtl_str.cxx @@ -29,7 +29,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <testshl/simpleheader.hxx> + +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <rtl/string.hxx> +#include <cstring> namespace rtl_str { @@ -253,7 +259,7 @@ namespace rtl_str { rtl::OString aStr1 = "Line for a hashCode."; sal_Int32 nHashCode = rtl_str_hashCode( aStr1.getStr() ); - t_print("hashcode: %d\n", nHashCode); + printf("hashcode: %d\n", nHashCode); // CPPUNIT_ASSERT_MESSAGE("failed.", nValue == 0); } @@ -638,7 +644,7 @@ namespace rtl_str rtl_str_toAsciiLowerCase_WithLength( pStr, 10 ); - t_print("Lowercase with length: '%s'\n", pStr); + printf("Lowercase with length: '%s'\n", pStr); CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(rtl::OString(pStr)) == sal_True); free(pStr); } @@ -710,7 +716,7 @@ namespace rtl_str strcpy(pStr, aStr1.getStr()); rtl_str_toAsciiUpperCase_WithLength( pStr, 10 ); - t_print("Uppercase with length: '%s'\n", aStr1.getStr()); + printf("Uppercase with length: '%s'\n", aStr1.getStr()); CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(rtl::OString(pStr)) == sal_True); free(pStr); } @@ -861,26 +867,26 @@ namespace rtl_str }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::compare, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::compareIgnoreAsciiCase, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::shortenedCompareIgnoreAsciiCase_WithLength, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::hashCode, "rtl_str"); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::compare); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::compareIgnoreAsciiCase); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::shortenedCompareIgnoreAsciiCase_WithLength); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::hashCode); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::indexOfChar, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::lastIndexOfChar, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::indexOfStr, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::lastIndexOfStr, "rtl_str"); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::indexOfChar); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::lastIndexOfChar); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::indexOfStr); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::lastIndexOfStr); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::replaceChar, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::replaceChar_WithLength, "rtl_str"); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::replaceChar); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::replaceChar_WithLength); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::toAsciiLowerCase, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::toAsciiLowerCase_WithLength, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::toAsciiUpperCase, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::toAsciiUpperCase_WithLength, "rtl_str"); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::toAsciiLowerCase); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::toAsciiLowerCase_WithLength); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::toAsciiUpperCase); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::toAsciiUpperCase_WithLength); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::trim_WithLength, "rtl_str"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::valueOfChar, "rtl_str"); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::trim_WithLength); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_str::valueOfChar); } // namespace rtl_str @@ -888,6 +894,6 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_str::valueOfChar, "rtl_str"); // 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; +CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/rtl/ostring/rtl_string.cxx b/sal/qa/rtl/ostring/rtl_string.cxx index d55e60e94e45..0b5e169d49bd 100644 --- a/sal/qa/rtl/ostring/rtl_string.cxx +++ b/sal/qa/rtl/ostring/rtl_string.cxx @@ -29,7 +29,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <testshl/simpleheader.hxx> + +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <rtl/ustring.hxx> +#include <cstring> namespace rtl_string { @@ -173,14 +179,14 @@ namespace rtl_string } // namespace rtl_string // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_string::getLength, "rtl_string"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_string::newFromString, "rtl_string"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_string::convertUStringToString, "rtl_string"); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_string::getLength); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_string::newFromString); +CPPUNIT_TEST_SUITE_REGISTRATION(rtl_string::convertUStringToString); // ----------------------------------------------------------------------------- // 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; +CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |