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/. */
8 ** Description: Test the functions and macros declared in prbit.h
14 #define ErrorReport(x) { printf((x)); failed = 1; }
16 prbitmap_t myMap[512/32] = { 0 };
22 int main(int argc, char **argv)
25 ** Test bitmap things.
27 if ( PR_TEST_BIT( myMap, 0 ))
28 ErrorReport("Test 0.0: Failed\n");
30 if ( PR_TEST_BIT( myMap, 31 ))
31 ErrorReport("Test 0.1: Failed\n");
33 if ( PR_TEST_BIT( myMap, 128 ))
34 ErrorReport("Test 0.2: Failed\n");
36 if ( PR_TEST_BIT( myMap, 129 ))
37 ErrorReport("Test 0.3: Failed\n");
40 PR_SET_BIT( myMap, 0 );
41 if ( !PR_TEST_BIT( myMap, 0 ))
42 ErrorReport("Test 1.0: Failed\n");
44 PR_CLEAR_BIT( myMap, 0 );
45 if ( PR_TEST_BIT( myMap, 0 ))
46 ErrorReport("Test 1.0.1: Failed\n");
48 PR_SET_BIT( myMap, 31 );
49 if ( !PR_TEST_BIT( myMap, 31 ))
50 ErrorReport("Test 1.1: Failed\n");
52 PR_CLEAR_BIT( myMap, 31 );
53 if ( PR_TEST_BIT( myMap, 31 ))
54 ErrorReport("Test 1.1.1: Failed\n");
56 PR_SET_BIT( myMap, 128 );
57 if ( !PR_TEST_BIT( myMap, 128 ))
58 ErrorReport("Test 1.2: Failed\n");
60 PR_CLEAR_BIT( myMap, 128 );
61 if ( PR_TEST_BIT( myMap, 128 ))
62 ErrorReport("Test 1.2.1: Failed\n");
64 PR_SET_BIT( myMap, 129 );
65 if ( !PR_TEST_BIT( myMap, 129 ))
66 ErrorReport("Test 1.3: Failed\n");
68 PR_CLEAR_BIT( myMap, 129 );
69 if ( PR_TEST_BIT( myMap, 129 ))
70 ErrorReport("Test 1.3.1: Failed\n");
74 ** Test Ceiling and Floor functions and macros
76 if ((rc = PR_CeilingLog2(32)) != 5 )
77 ErrorReport("Test 10.0: Failed\n");
79 if ((rc = PR_FloorLog2(32)) != 5 )
80 ErrorReport("Test 10.1: Failed\n");
84 ** Evaluate results and exit