Pin down LoadStringA behaviour on different buffer lengths.
This commit is contained in:
parent
2a2cd4db76
commit
88bc174873
|
@ -4,6 +4,8 @@ generated.ok
|
|||
input.ok
|
||||
listbox.ok
|
||||
msg.ok
|
||||
resource.ok
|
||||
resource.res
|
||||
sysparams.ok
|
||||
testlist.c
|
||||
user32_test.exe.spec.c
|
||||
|
|
|
@ -11,10 +11,13 @@ CTESTS = \
|
|||
input.c \
|
||||
listbox.c \
|
||||
msg.c \
|
||||
resource.c \
|
||||
sysparams.c \
|
||||
win.c \
|
||||
wsprintf.c
|
||||
|
||||
RC_SRCS = resource.rc
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
||||
### Dependencies:
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* Unit test suite for resources.
|
||||
*
|
||||
* Copyright 2004 Ferenc Wagner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
void
|
||||
test_LoadStringA (void)
|
||||
{
|
||||
HINSTANCE hInst = GetModuleHandle (NULL);
|
||||
const char str[] = "String resource"; /* same in resource.rc */
|
||||
char buf[128];
|
||||
struct string_test {
|
||||
int bufsiz;
|
||||
int expected;
|
||||
};
|
||||
struct string_test tests[] = {{sizeof buf, sizeof str - 1},
|
||||
{sizeof str, sizeof str - 1},
|
||||
{sizeof str - 1, sizeof str - 2}};
|
||||
int i;
|
||||
|
||||
assert (sizeof str < sizeof buf);
|
||||
for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
|
||||
const int bufsiz = tests[i].bufsiz;
|
||||
const int expected = tests[i].expected;
|
||||
const int len = LoadStringA (hInst, 0, buf, bufsiz);
|
||||
|
||||
ok (len == expected, "bufsiz=%d: got %d, expected %d",
|
||||
bufsiz, len, expected);
|
||||
ok (!memcmp (buf, str, len),
|
||||
"bufsiz=%d: got '%s', expected '%.*s'",
|
||||
bufsiz, buf, len, str);
|
||||
ok (buf[len] == 0, "bufsiz=%d: NUL termination missing",
|
||||
bufsiz);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(resource)
|
||||
{
|
||||
test_LoadStringA ();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/* Unit test suite for resources.
|
||||
*
|
||||
* Copyright 2004 Ferenc Wagner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
STRINGTABLE {
|
||||
0 "String resource"
|
||||
}
|
Loading…
Reference in New Issue