| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
*/ |
| 9 |
|
| 10 |
#include <sal/config.h> |
| 11 |
|
| 12 |
#include <rtl/string.h> |
| 13 |
#include <rtl/ustring.hxx> |
| 14 |
|
| 15 |
// expected-note@rtl/ustring.hxx:* 1+ {{}} |
| 16 |
|
| 17 |
void checkExtraIntArgument() |
| 18 |
{ |
| 19 |
// This makes sure that using by mistake RTL_CONSTASCII_STRINGPARAM does not trigger a different |
| 20 |
// overload, i.e. the second argument to match() in this case is the indexFrom argument, |
| 21 |
// but with the macro it would contain the length of the string. Therefore |
| 22 |
// match( RTL_CONSTASCII_STRINGPARAM( "bar" )) would be match( "bar", 3 ), which would be |
| 23 |
// true when called for OUString( "foobar" ). But this should not happen because of the |
| 24 |
// &foo[0] trick in the RTL_CONSTASCII_STRINGPARAM macro. |
| 25 |
// expected-error@+1 {{}} |
| 26 |
OUString("foobar").match(RTL_CONSTASCII_STRINGPARAM("bar")); |
| 27 |
} |
| 28 |
|
| 29 |
void checkNonconstChar() |
| 30 |
{ |
| 31 |
// check that non-const char[] data do not trigger string literal overloads |
| 32 |
char test[] = "test"; |
| 33 |
char bar[] = "bar"; |
| 34 |
const char consttest[] = "test"; |
| 35 |
const char constbar[] = "bar"; |
| 36 |
// expected-error@+1 {{}} |
| 37 |
(void)OUString("footest").replaceAll(test, bar); |
| 38 |
// expected-error@+1 {{}} |
| 39 |
(void)OUString("footest").replaceAll(consttest, bar); |
| 40 |
// expected-error@+1 {{}} |
| 41 |
(void)OUString("footest").replaceAll(test, constbar); |
| 42 |
(void)OUString("footest").replaceAll(consttest, constbar); |
| 43 |
} |
| 44 |
|
| 45 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |