Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / wcrtomb.c
blob64cbd99b9ad21a646cf90078c87ce09bc027c97d
1 // RUN: %clang %s -o %t && %run %t 2>&1
3 #include <assert.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <wchar.h>
8 int main(int argc, char **argv) {
9 mbstate_t state;
10 memset(&state, 0, sizeof(state));
12 char buff[10];
13 size_t res = wcrtomb(buff, L'a', &state);
14 assert(res == 1);
15 assert(buff[0] == 'a');
17 res = wcrtomb(buff, L'\0', &state);
18 assert(res == 1);
19 assert(buff[0] == '\0');
21 res = wcrtomb(NULL, L'\0', &state);
22 assert(res == 1);
24 res = wcrtomb(buff, L'a', NULL);
25 assert(res == 1);
26 assert(buff[0] == 'a');
28 res = wcrtomb(buff, L'\0', NULL);
29 assert(res == 1);
30 assert(buff[0] == '\0');
32 res = wcrtomb(NULL, L'\0', NULL);
33 assert(res == 1);
35 return 0;