1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is the Netscape Portable Runtime (NSPR).
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998-2000
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the MPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the MPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
41
** This is a simple test of the PR_snprintf() function defined
44
** Modification History:
45
** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
46
** The debug mode will print all of the printfs associated with this test.
47
** The regress mode will be the default mode. Since the regress tool limits
48
** the output to a one line status:PASS or FAIL,all of the printf statements
49
** have been handled with an if (debug_mode) statement.
50
***********************************************************************/
51
/***********************************************************************
53
***********************************************************************/
54
/* Used to get the command line option */
66
/***********************************************************************
67
** PRIVATE FUNCTION: Test_Result
68
** DESCRIPTION: Used in conjunction with the regress tool, prints out the
69
** status of the test case.
78
** ALGORITHM: Determine what the status is and print accordingly.
80
***********************************************************************/
83
static void Test_Result (int result)
91
int main( int argc, char *argv[])
98
char answer[BUF_SIZE];
101
/* The command line argument: -d is used to determine if the test is being run
102
in debug mode. The regress tool requires only one line output:PASS or FAIL.
103
All of the printfs associated with this test has been handled with a if (debug_mode)
108
PLOptState *opt = PL_CreateOptState(argc, argv, "d:");
109
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
111
if (PL_OPT_BAD == os) continue;
114
case 'd': /* debug mode */
121
PL_DestroyOptState(opt);
131
PR_snprintf(buf, BUF_SIZE, "%hx %x %lx %llx", i16, n, i32, i64);
132
strcpy(answer, "ffff ");
133
for (i = PR_BYTES_PER_INT * 2; i; i--) {
136
strcat(answer, " ffffffff ffffffffffffffff");
138
if (!strcmp(buf, answer)) {
139
if (debug_mode) printf("PR_snprintf test 1 passed\n");
140
else Test_Result (PASS);
143
printf("PR_snprintf test 1 failed\n");
144
printf("Converted string is %s\n", buf);
145
printf("Should be %s\n", answer);