2 * Copyright 2010 Piotr Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
25 static void* (__cdecl *p_set_invalid_parameter_handler)(void*);
27 static void (__cdecl *p_char_assign)(void*, const void*);
28 static void (__cdecl *p_wchar_assign)(void*, const void*);
29 static void (__cdecl *p_short_assign)(void*, const void*);
31 static int invalid_parameter = 0;
32 static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
33 const wchar_t *function, const wchar_t *file,
34 unsigned line, uintptr_t arg)
36 ok(expression == NULL, "expression is not NULL\n");
37 ok(function == NULL, "function is not NULL\n");
38 ok(file == NULL, "file is not NULL\n");
39 ok(line == 0, "line = %u\n", line);
40 ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
44 static BOOL init(void)
46 HMODULE msvcr = LoadLibraryA("msvcr90.dll");
47 HMODULE msvcp = LoadLibraryA("msvcp90.dll");
48 if(!msvcr || !msvcp) {
49 win_skip("msvcp90.dll or msvcrt90.dll not installed\n");
53 p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
54 if(!p_set_invalid_parameter_handler) {
55 win_skip("Error setting tests environment\n");
59 p_set_invalid_parameter_handler(test_invalid_parameter_handler);
61 p_char_assign = (void*)GetProcAddress(msvcp, "?assign@?$char_traits@D@std@@SAXAADABD@Z");
62 p_wchar_assign = (void*)GetProcAddress(msvcp, "?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z");
63 p_short_assign = (void*)GetProcAddress(msvcp, "?assign@?$char_traits@G@std@@SAXAAGABG@Z");
68 static void test_assign(void)
70 const char in[] = "abc";
73 if(!p_char_assign || !p_wchar_assign || !p_short_assign) {
74 win_skip("assign tests skipped\n");
79 p_char_assign(out, in);
80 ok(out[0] == in[0], "out[0] = %c\n", out[0]);
81 ok(out[1] == '#', "out[1] = %c\n", out[1]);
84 p_wchar_assign(out, in);
85 ok(*((char*)out)==in[0] && *((char*)out+1)==in[1],
86 "out[0] = %d, out[1] = %d\n", (int)out[0], (int)out[1]);
87 ok(out[2] == '#', "out[2] = %c\n", out[2]);
90 p_short_assign(out, in);
91 ok(*((char*)out)==in[0] && *((char*)out+1)==in[1],
92 "out[0] = %d, out[1] = %d\n", (int)out[0], (int)out[1]);
93 ok(out[2] == '#', "out[2] = %c\n", out[2]);
103 ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");