|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 ** File: lazyinit.c |
|
8 ** Description: Test the functions and macros declared in prbit.h |
|
9 ** |
|
10 */ |
|
11 |
|
12 #include "nspr.h" |
|
13 |
|
14 #define ErrorReport(x) { printf((x)); failed = 1; } |
|
15 |
|
16 prbitmap_t myMap[512/32] = { 0 }; |
|
17 |
|
18 PRInt32 rc; |
|
19 PRInt32 i; |
|
20 PRIntn failed = 0; |
|
21 |
|
22 int main(int argc, char **argv) |
|
23 { |
|
24 /* |
|
25 ** Test bitmap things. |
|
26 */ |
|
27 if ( PR_TEST_BIT( myMap, 0 )) |
|
28 ErrorReport("Test 0.0: Failed\n"); |
|
29 |
|
30 if ( PR_TEST_BIT( myMap, 31 )) |
|
31 ErrorReport("Test 0.1: Failed\n"); |
|
32 |
|
33 if ( PR_TEST_BIT( myMap, 128 )) |
|
34 ErrorReport("Test 0.2: Failed\n"); |
|
35 |
|
36 if ( PR_TEST_BIT( myMap, 129 )) |
|
37 ErrorReport("Test 0.3: Failed\n"); |
|
38 |
|
39 |
|
40 PR_SET_BIT( myMap, 0 ); |
|
41 if ( !PR_TEST_BIT( myMap, 0 )) |
|
42 ErrorReport("Test 1.0: Failed\n"); |
|
43 |
|
44 PR_CLEAR_BIT( myMap, 0 ); |
|
45 if ( PR_TEST_BIT( myMap, 0 )) |
|
46 ErrorReport("Test 1.0.1: Failed\n"); |
|
47 |
|
48 PR_SET_BIT( myMap, 31 ); |
|
49 if ( !PR_TEST_BIT( myMap, 31 )) |
|
50 ErrorReport("Test 1.1: Failed\n"); |
|
51 |
|
52 PR_CLEAR_BIT( myMap, 31 ); |
|
53 if ( PR_TEST_BIT( myMap, 31 )) |
|
54 ErrorReport("Test 1.1.1: Failed\n"); |
|
55 |
|
56 PR_SET_BIT( myMap, 128 ); |
|
57 if ( !PR_TEST_BIT( myMap, 128 )) |
|
58 ErrorReport("Test 1.2: Failed\n"); |
|
59 |
|
60 PR_CLEAR_BIT( myMap, 128 ); |
|
61 if ( PR_TEST_BIT( myMap, 128 )) |
|
62 ErrorReport("Test 1.2.1: Failed\n"); |
|
63 |
|
64 PR_SET_BIT( myMap, 129 ); |
|
65 if ( !PR_TEST_BIT( myMap, 129 )) |
|
66 ErrorReport("Test 1.3: Failed\n"); |
|
67 |
|
68 PR_CLEAR_BIT( myMap, 129 ); |
|
69 if ( PR_TEST_BIT( myMap, 129 )) |
|
70 ErrorReport("Test 1.3.1: Failed\n"); |
|
71 |
|
72 |
|
73 /* |
|
74 ** Test Ceiling and Floor functions and macros |
|
75 */ |
|
76 if ((rc = PR_CeilingLog2(32)) != 5 ) |
|
77 ErrorReport("Test 10.0: Failed\n"); |
|
78 |
|
79 if ((rc = PR_FloorLog2(32)) != 5 ) |
|
80 ErrorReport("Test 10.1: Failed\n"); |
|
81 |
|
82 |
|
83 /* |
|
84 ** Evaluate results and exit |
|
85 */ |
|
86 if (failed) |
|
87 { |
|
88 printf("FAILED\n"); |
|
89 return(1); |
|
90 } |
|
91 else |
|
92 { |
|
93 printf("PASSED\n"); |
|
94 return(0); |
|
95 } |
|
96 } /* end main() */ |
|
97 /* end testbit.c */ |