]>
Commit | Line | Data |
---|---|---|
14c7c974 A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
4f6e3300 A |
6 | * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights |
7 | * Reserved. This file contains Original Code and/or Modifications of | |
8 | * Original Code as defined in and that are subject to the Apple Public | |
9 | * Source License Version 1.1 (the "License"). You may not use this file | |
10 | * except in compliance with the License. Please obtain a copy of the | |
11 | * License at http://www.apple.com/publicsource and read it before using | |
12 | * this file. | |
14c7c974 A |
13 | * |
14 | * The Original Code and all software distributed under the License are | |
4f6e3300 | 15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
14c7c974 A |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
4f6e3300 A |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the |
19 | * License for the specific language governing rights and limitations | |
20 | * under the License. | |
14c7c974 A |
21 | * |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | /* test standalone library */ | |
25 | #include <stdarg.h> | |
26 | ||
27 | #define TEST_RESULT "The quick brown #5 fox did fine.\n" | |
28 | #define TEST_FMT "The quick %s #%d fox did fine.\n" | |
29 | #define TEST_ARGS "brown", 5 | |
30 | ||
31 | char error_buf[1024]; | |
32 | char *sa_rld_error_buf_addr = error_buf; | |
33 | int sa_rld_error_buf_size = 1024; | |
34 | char progname[] = "satest"; | |
35 | ||
36 | /* | |
37 | * All printing of all messages goes through this function. | |
38 | */ | |
39 | void | |
40 | vprint( | |
41 | const char *format, | |
42 | va_list ap) | |
43 | { | |
44 | sa_rld_error_buf_size =- slvprintf(sa_rld_error_buf_addr, | |
45 | sa_rld_error_buf_size, | |
46 | format, ap); | |
47 | } | |
48 | /* | |
49 | * Print the error message and set the 'error' indication. | |
50 | */ | |
51 | void | |
52 | error( | |
53 | const char *format, | |
54 | ...) | |
55 | { | |
56 | va_list ap; | |
57 | ||
58 | // if(arch_multiple) | |
59 | // print_architecture_banner(); | |
60 | va_start(ap, format); | |
61 | // print("%s: ", progname); | |
62 | vprint(format, ap); | |
63 | // print("\n"); | |
64 | va_end(ap); | |
65 | // errors = 1; | |
66 | } | |
67 | ||
68 | main() | |
69 | { | |
70 | char buf[1024]; | |
71 | int args[4], ret; | |
72 | ||
73 | printf("Testing standalone library\n"); | |
74 | printf("The following two lines should be identical:\n"); | |
75 | sprintf(buf, TEST_FMT, TEST_ARGS); | |
76 | printf(buf); | |
77 | printf(TEST_RESULT); | |
78 | printf("\nThe following two lines should be identical:\n"); | |
79 | error(TEST_FMT, TEST_ARGS); | |
80 | printf(error_buf); | |
81 | printf(TEST_RESULT); | |
82 | ||
83 | printf("Comparing two strings:\n"); | |
84 | ret = strcmp("abra","cadabra"); | |
85 | printf("%d should not be 0.\n",ret); | |
86 | ||
87 | printf("Comparing two strings:\n"); | |
88 | ret = strcmp("abra","abra"); | |
89 | printf("%d should be 0.\n",ret); | |
90 | ||
91 | printf("Comparing two strings:\n"); | |
92 | ret = strncmp("abcdefghij","abcdef",6); | |
93 | printf("%d should be 0.\n",ret); | |
94 | ||
95 | printf("printf(\"Test: %% 12s\\n\",\"abb\");\n"); | |
96 | printf("Test: abb\n"); | |
97 | printf("Test: % 12s\n","abb"); | |
98 | ||
99 | printf("printf(\"Test: %%04d\\n\",77);\n"); | |
100 | printf("Test: 0077\n"); | |
101 | printf("Test: %04d\n",77); | |
102 | ||
103 | printf("printf(\"Test: %% 2d\\n\",9);\n"); | |
104 | printf("Test: 9\n"); | |
105 | printf("Test: % 2d\n",9); | |
106 | ||
107 | printf("printf(\"Test: %% 8d\\n\",-9);\n"); | |
108 | printf("Test: -9\n"); | |
109 | printf("Test: % 8d\n",-9); | |
110 | } |