Expand PMF_FN_* macros.
[netbsd-mini2440.git] / regress / lib / libutil / snprintb / snprintbtest.c
blob36493a4f8e4571e95eabd603325bfe66f17c0648
1 /* $NetBSD: snprintbtest.c,v 1.2 2002/09/21 07:33:25 petrov Exp $ */
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code was contributed to The NetBSD Foundation by Christos Zoulas.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
31 #include <string.h>
32 #include <util.h>
33 #include <err.h>
35 struct {
36 const char *fmt;
37 uint64_t val;
38 const char *res;
39 } test[] = {
41 "\10\2BITTWO\1BITONE",
42 3,
43 "03<BITTWO,BITONE>"
46 "\177\20b\05NOTBOOT\0b\06FPP\0b\013SDVMA\0b\015VIDEO\0"
47 "b\020LORES\0b\021FPA\0b\022DIAG\0b\016CACHE\0"
48 "b\017IOCACHE\0b\022LOOPBACK\0b\04DBGCACHE\0",
49 0xe860,
50 "0xe860<NOTBOOT,FPP,SDVMA,VIDEO,CACHE,IOCACHE>"
54 int
55 main(int argc, char *argv[])
57 char buf[1024];
58 size_t i;
60 for (i = 0; i < sizeof(test) / sizeof(test[0]); i++) {
61 int len = snprintb(buf, sizeof(buf), test[i].fmt, test[i].val);
62 int slen = (int)strlen(test[i].res);
63 if (strcmp(test[i].res, buf) != 0)
64 errx(1, "Unexpected result `%s' != `%s'\n",
65 buf, test[i].res);
66 if (len != slen)
67 errx(1, "Unexpected len in result %d != %d\n",
68 len, slen);
70 return 0;