VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/tests/testbit.c@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
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
4 *
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/
9 *
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
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
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.
21 *
22 * Contributor(s):
23 *
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.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38/*
39** File: lazyinit.c
40** Description: Test the functions and macros declared in prbit.h
41**
42*/
43
44#include "nspr.h"
45
46#define ErrorReport(x) { printf((x)); failed = 1; }
47
48prbitmap_t myMap[512/32] = { 0 };
49
50PRInt32 rc;
51PRInt32 i;
52PRIntn failed = 0;
53
54PRIntn main(PRIntn argc, char **argv )
55{
56 /*
57 ** Test bitmap things.
58 */
59 if ( PR_TEST_BIT( myMap, 0 ))
60 ErrorReport("Test 0.0: Failed\n");
61
62 if ( PR_TEST_BIT( myMap, 31 ))
63 ErrorReport("Test 0.1: Failed\n");
64
65 if ( PR_TEST_BIT( myMap, 128 ))
66 ErrorReport("Test 0.2: Failed\n");
67
68 if ( PR_TEST_BIT( myMap, 129 ))
69 ErrorReport("Test 0.3: Failed\n");
70
71
72 PR_SET_BIT( myMap, 0 );
73 if ( !PR_TEST_BIT( myMap, 0 ))
74 ErrorReport("Test 1.0: Failed\n");
75
76 PR_CLEAR_BIT( myMap, 0 );
77 if ( PR_TEST_BIT( myMap, 0 ))
78 ErrorReport("Test 1.0.1: Failed\n");
79
80 PR_SET_BIT( myMap, 31 );
81 if ( !PR_TEST_BIT( myMap, 31 ))
82 ErrorReport("Test 1.1: Failed\n");
83
84 PR_CLEAR_BIT( myMap, 31 );
85 if ( PR_TEST_BIT( myMap, 31 ))
86 ErrorReport("Test 1.1.1: Failed\n");
87
88 PR_SET_BIT( myMap, 128 );
89 if ( !PR_TEST_BIT( myMap, 128 ))
90 ErrorReport("Test 1.2: Failed\n");
91
92 PR_CLEAR_BIT( myMap, 128 );
93 if ( PR_TEST_BIT( myMap, 128 ))
94 ErrorReport("Test 1.2.1: Failed\n");
95
96 PR_SET_BIT( myMap, 129 );
97 if ( !PR_TEST_BIT( myMap, 129 ))
98 ErrorReport("Test 1.3: Failed\n");
99
100 PR_CLEAR_BIT( myMap, 129 );
101 if ( PR_TEST_BIT( myMap, 129 ))
102 ErrorReport("Test 1.3.1: Failed\n");
103
104
105 /*
106 ** Test Ceiling and Floor functions and macros
107 */
108 if ((rc = PR_CeilingLog2(32)) != 5 )
109 ErrorReport("Test 10.0: Failed\n");
110
111 if ((rc = PR_FloorLog2(32)) != 5 )
112 ErrorReport("Test 10.1: Failed\n");
113
114
115 /*
116 ** Evaluate results and exit
117 */
118 if (failed)
119 {
120 printf("FAILED\n");
121 return(1);
122 }
123 else
124 {
125 printf("PASSED\n");
126 return(0);
127 }
128} /* end main() */
129/* end testbit.c */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette