|
1 /* -*- Mode: C++; tab-width: 2; 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 file, |
|
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "mozilla/MathAlgorithms.h" |
|
7 |
|
8 using mozilla::CountPopulation32; |
|
9 |
|
10 static void |
|
11 TestCountPopulation32() |
|
12 { |
|
13 MOZ_RELEASE_ASSERT(CountPopulation32(0xFFFFFFFF) == 32); |
|
14 MOZ_RELEASE_ASSERT(CountPopulation32(0xF0FF1000) == 13); |
|
15 MOZ_RELEASE_ASSERT(CountPopulation32(0x7F8F0001) == 13); |
|
16 MOZ_RELEASE_ASSERT(CountPopulation32(0x3FFF0100) == 15); |
|
17 MOZ_RELEASE_ASSERT(CountPopulation32(0x1FF50010) == 12); |
|
18 MOZ_RELEASE_ASSERT(CountPopulation32(0x00800000) == 1); |
|
19 MOZ_RELEASE_ASSERT(CountPopulation32(0x00400000) == 1); |
|
20 MOZ_RELEASE_ASSERT(CountPopulation32(0x00008000) == 1); |
|
21 MOZ_RELEASE_ASSERT(CountPopulation32(0x00004000) == 1); |
|
22 MOZ_RELEASE_ASSERT(CountPopulation32(0x00000080) == 1); |
|
23 MOZ_RELEASE_ASSERT(CountPopulation32(0x00000040) == 1); |
|
24 MOZ_RELEASE_ASSERT(CountPopulation32(0x00000001) == 1); |
|
25 MOZ_RELEASE_ASSERT(CountPopulation32(0x00000000) == 0); |
|
26 } |
|
27 |
|
28 int main() |
|
29 { |
|
30 TestCountPopulation32(); |
|
31 return 0; |
|
32 } |