tst.basics.d revision 256281
1218885Sdim/*
2218885Sdim * CDDL HEADER START
3218885Sdim *
4218885Sdim * The contents of this file are subject to the terms of the
5218885Sdim * Common Development and Distribution License (the "License").
6218885Sdim * You may not use this file except in compliance with the License.
7218885Sdim *
8218885Sdim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9218885Sdim * or http://www.opensolaris.org/os/licensing.
10218885Sdim * See the License for the specific language governing permissions
11218885Sdim * and limitations under the License.
12218885Sdim *
13218885Sdim * When distributing Covered Code, include this CDDL HEADER in each
14221345Sdim * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15218885Sdim * If applicable, add the following below this CDDL HEADER, with the
16218885Sdim * fields enclosed by brackets "[]" replaced with your own identifying
17221345Sdim * information: Portions Copyright [yyyy] [name of copyright owner]
18223017Sdim *
19221345Sdim * CDDL HEADER END
20218885Sdim */
21218885Sdim
22218885Sdim/*
23221345Sdim * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24221345Sdim * Use is subject to license terms.
25218885Sdim */
26218885Sdim
27218885Sdim#pragma ident	"%Z%%M%	%I%	%E% SMI"
28223017Sdim
29223017Sdim/*
30223017Sdim * ASSERTION:
31223017Sdim *  Test the basics of all the format conversions in the printf dictionary.
32221345Sdim *
33221345Sdim * SECTION: Output Formatting/printf()
34221345Sdim *
35221345Sdim * NOTES:
36221345Sdim *  floats and wchar_t strings missing
37221345Sdim */
38221345Sdim
39221345Sdim#pragma D option quiet
40221345Sdim
41221345SdimBEGIN
42218885Sdim{
43218885Sdim	i = (int)'a';
44221345Sdim
45221345Sdim	printf("\n");
46221345Sdim
47221345Sdim	printf("%%a = %a\n", &`kmem_alloc);
48221345Sdim	printf("%%c = %c\n", i);
49221345Sdim	printf("%%d = %d\n", i);
50221345Sdim	printf("%%hd = %hd\n", (short)i);
51221345Sdim	printf("%%hi = %hi\n", (short)i);
52221345Sdim	printf("%%ho = %ho\n", (ushort_t)i);
53221345Sdim	printf("%%hu = %hu\n", (ushort_t)i);
54221345Sdim	printf("%%hx = %hx\n", (ushort_t)i);
55221345Sdim	printf("%%hX = %hX\n", (ushort_t)i);
56218885Sdim	printf("%%i = %i\n", i);
57218885Sdim	printf("%%lc = %lc\n", i);
58218885Sdim	printf("%%ld = %ld\n", (long)i);
59218885Sdim	printf("%%li = %li\n", (long)i);
60218885Sdim	printf("%%lo = %lo\n", (ulong_t)i);
61218885Sdim	printf("%%lu = %lu\n", (ulong_t)i);
62218885Sdim	printf("%%lx = %lx\n", (ulong_t)i);
63218885Sdim	printf("%%lX = %lX\n", (ulong_t)i);
64218885Sdim	printf("%%o = %o\n", (uint_t)i);
65218885Sdim	printf("%%p = %p\n", (void *)i);
66218885Sdim	printf("%%s = %s\n", "hello");
67221345Sdim	printf("%%u = %u\n", (uint_t)i);
68218885Sdim	printf("%%wc = %wc\n", i);
69218885Sdim	printf("%%x = %x\n", (uint_t)i);
70218885Sdim	printf("%%X = %X\n", (uint_t)i);
71218885Sdim
72218885Sdim	exit(0);
73218885Sdim}
74218885Sdim