File: swprintf.c

package info (click to toggle)
picolibc 1.8.11-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 50,064 kB
  • sloc: ansic: 404,031; asm: 24,984; sh: 2,585; python: 2,289; perl: 680; pascal: 329; exp: 287; makefile: 222; cpp: 71; xml: 40
file content (34 lines) | stat: -rw-r--r-- 760 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright (C) 2011 by ARM Ltd. All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * is freely granted, provided that this notice is preserved.
 */

#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <string.h>
#include "check.h"

int
main(void)
{
#if defined(INTEGER_ONLY) || defined(__IO_NO_FLOATING_POINT)

#else
    char    cbuf[512];
    wchar_t wcbuf[512], wcbuf2[512];
    double  val = 1E+30;
    memset(cbuf, 0xdd, sizeof(cbuf));
    memset(wcbuf, 0xdd, sizeof(wcbuf));
    memset(wcbuf2, 0xd, sizeof(wcbuf2));
    snprintf(cbuf, 512, "%.*f", 3, val);
    swprintf(wcbuf, 512, L"%.*f", 3, val);
    mbstowcs(wcbuf2, cbuf, 512);

    CHECK(wcscmp(wcbuf, wcbuf2) == 0);
#endif

    exit(0);
}