mfbt/tests/TestCountPopulation.cpp

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     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/. */
     6 #include "mozilla/MathAlgorithms.h"
     8 using mozilla::CountPopulation32;
    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 }
    28 int main()
    29 {
    30   TestCountPopulation32();
    31   return 0;
    32 }

mercurial