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 ** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
51 ** recognize the return code from tha main program.
52 ***********************************************************************/
53 /***********************************************************************
55 ***********************************************************************/
56 /* Used to get the command line option */
67 PRIntn failed_already
=0;
70 int main( int argc
, char *argv
[])
78 /* The command line argument: -d is used to determine if the test is being run
79 in debug mode. The regress tool requires only one line output:PASS or FAIL.
80 All of the printfs associated with this test has been handled with a if (debug_mode)
85 PLOptState
*opt
= PL_CreateOptState(argc
, argv
, "d:");
86 while (PL_OPT_EOL
!= (os
= PL_GetNextOpt(opt
)))
88 if (PL_OPT_BAD
== os
) continue;
91 case 'd': /* debug mode */
98 PL_DestroyOptState(opt
);
108 PR_snprintf(buf
, BUF_SIZE
, "%d %hd %lld %ld", n
, i16
, i64
, i32
);
109 if (!strcmp(buf
, "30 -32 333 64")) {
110 if (debug_mode
) printf("PR_snprintf test 2 passed\n");
113 printf("PR_snprintf test 2 failed\n");
114 printf("Converted string is %s\n", buf
);
115 printf("Should be 30 -32 333 64\n");
117 else failed_already
=1;