makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / msvcr110 / tests / msvcr110.c
blob09876131f072264526bd4b45a6fc2981c665bf45
1 /*
2 * Copyright 2018 Daniel Lehman
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
19 #include <errno.h>
20 #include <stdarg.h>
21 #include <stdlib.h>
22 #include <wchar.h>
23 #include <stdio.h>
24 #include <float.h>
25 #include <limits.h>
27 #include <windef.h>
28 #include <winbase.h>
29 #include <winnls.h>
30 #include "wine/test.h"
32 #include <locale.h>
34 static char* (CDECL *p_setlocale)(int category, const char* locale);
35 static size_t (CDECL *p___strncnt)(const char *str, size_t count);
37 static unsigned int (CDECL *p_CurrentScheduler_GetNumberOfVirtualProcessors)(void);
38 static unsigned int (CDECL *p__CurrentScheduler__GetNumberOfVirtualProcessors)(void);
39 static unsigned int (CDECL *p_CurrentScheduler_Id)(void);
40 static unsigned int (CDECL *p__CurrentScheduler__Id)(void);
42 static BOOL init(void)
44 HMODULE module;
46 module = LoadLibraryA("msvcr110.dll");
47 if (!module)
49 win_skip("msvcr110.dll not installed\n");
50 return FALSE;
53 p_setlocale = (void*)GetProcAddress(module, "setlocale");
54 p___strncnt = (void*)GetProcAddress(module, "__strncnt");
55 p_CurrentScheduler_GetNumberOfVirtualProcessors = (void*)GetProcAddress(module, "?GetNumberOfVirtualProcessors@CurrentScheduler@Concurrency@@SAIXZ");
56 p__CurrentScheduler__GetNumberOfVirtualProcessors = (void*)GetProcAddress(module, "?_GetNumberOfVirtualProcessors@_CurrentScheduler@details@Concurrency@@SAIXZ");
57 p_CurrentScheduler_Id = (void*)GetProcAddress(module, "?Id@CurrentScheduler@Concurrency@@SAIXZ");
58 p__CurrentScheduler__Id = (void*)GetProcAddress(module, "?_Id@_CurrentScheduler@details@Concurrency@@SAIXZ");
60 return TRUE;
63 static void test_CurrentScheduler(void)
65 unsigned int id;
66 unsigned int ncpus;
67 unsigned int expect;
68 SYSTEM_INFO si;
70 expect = ~0;
71 ncpus = p_CurrentScheduler_GetNumberOfVirtualProcessors();
72 ok(ncpus == expect, "expected %x, got %x\n", expect, ncpus);
73 id = p_CurrentScheduler_Id();
74 ok(id == expect, "expected %u, got %u\n", expect, id);
76 GetSystemInfo(&si);
77 expect = si.dwNumberOfProcessors;
78 /* these _CurrentScheduler calls trigger scheduler creation
79 if either is commented out, the following CurrentScheduler (no _) tests will still work */
80 ncpus = p__CurrentScheduler__GetNumberOfVirtualProcessors();
81 id = p__CurrentScheduler__Id();
82 ok(ncpus == expect, "expected %u, got %u\n", expect, ncpus);
83 ok(id == 0, "expected 0, got %u\n", id);
85 /* these CurrentScheduler tests assume scheduler is created */
86 ncpus = p_CurrentScheduler_GetNumberOfVirtualProcessors();
87 ok(ncpus == expect, "expected %u, got %u\n", expect, ncpus);
88 id = p_CurrentScheduler_Id();
89 ok(id == 0, "expected 0, got %u\n", id);
92 static void test_setlocale(void)
94 int i;
95 char *ret;
96 static const char *names[] =
98 "en-us",
99 "en-US",
100 "EN-US",
101 "syr-SY",
102 "uz-Latn-uz",
105 for(i=0; i<ARRAY_SIZE(names); i++) {
106 ret = p_setlocale(LC_ALL, names[i]);
107 ok(ret != NULL, "expected success, but got NULL\n");
108 ok(!strcmp(ret, names[i]), "expected %s, got %s\n", names[i], ret);
111 ret = p_setlocale(LC_ALL, "en-us.1250");
112 ok(!ret, "setlocale(en-us.1250) succeeded (%s)\n", ret);
114 p_setlocale(LC_ALL, "C");
117 static void test___strncnt(void)
119 static const struct
121 const char *str;
122 size_t size;
123 size_t ret;
125 strncnt_tests[] =
127 { NULL, 0, 0 },
128 { "a", 0, 0 },
129 { "a", 1, 1 },
130 { "a", 10, 1 },
131 { "abc", 1, 1 },
133 unsigned int i;
134 size_t ret;
136 if (0) /* crashes */
137 ret = p___strncnt(NULL, 1);
139 for (i = 0; i < ARRAY_SIZE(strncnt_tests); ++i)
141 ret = p___strncnt(strncnt_tests[i].str, strncnt_tests[i].size);
142 ok(ret == strncnt_tests[i].ret, "%u: unexpected return value %u.\n", i, (int)ret);
146 START_TEST(msvcr110)
148 if (!init()) return;
149 test_CurrentScheduler(); /* MUST be first (at least among Concurrency tests) */
150 test_setlocale();
151 test___strncnt();