brintos

brintos / llvm-project-archived public Read only

0
0
Text · 701 B · 64cbd99 Raw
37 lines · c
1// RUN: %clang %s -o %t && %run %t 2>&12 3#include <assert.h>4#include <stdlib.h>5#include <string.h>6#include <wchar.h>7 8int main(int argc, char **argv) {9  mbstate_t state;10  memset(&state, 0, sizeof(state));11 12  char buff[10];13  size_t res = wcrtomb(buff, L'a', &state);14  assert(res == 1);15  assert(buff[0] == 'a');16 17  res = wcrtomb(buff, L'\0', &state);18  assert(res == 1);19  assert(buff[0] == '\0');20 21  res = wcrtomb(NULL, L'\0', &state);22  assert(res == 1);23 24  res = wcrtomb(buff, L'a', NULL);25  assert(res == 1);26  assert(buff[0] == 'a');27 28  res = wcrtomb(buff, L'\0', NULL);29  assert(res == 1);30  assert(buff[0] == '\0');31 32  res = wcrtomb(NULL, L'\0', NULL);33  assert(res == 1);34 35  return 0;36}37