test/hotspot/gtest/metaspace/test_blockListArray.cpp
branchstuefe-new-metaspace-branch
changeset 59238 6ce12ce00d3e
child 59271 1558266946de
equal deleted inserted replaced
59155:b537e6386306 59238:6ce12ce00d3e
       
     1 /*
       
     2  * Copyright (c) 2019, SAP SE. All rights reserved.
       
     3  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
       
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     5  *
       
     6  * This code is free software; you can redistribute it and/or modify it
       
     7  * under the terms of the GNU General Public License version 2 only, as
       
     8  * published by the Free Software Foundation.
       
     9  *
       
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    13  * version 2 for more details (a copy is included in the LICENSE file that
       
    14  * accompanied this code).
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License version
       
    17  * 2 along with this work; if not, write to the Free Software Foundation,
       
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    19  *
       
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    21  * or visit www.oracle.com if you need additional information or have any
       
    22  * questions.
       
    23  */
       
    24 
       
    25 
       
    26 #include "precompiled.hpp"
       
    27 
       
    28 //#define LOG_PLEASE
       
    29 
       
    30 #include "metaspaceTestsCommon.hpp"
       
    31 
       
    32 TEST_VM(metaspace, BlockListFreeMap_mask_basic) {
       
    33   // Basic tests
       
    34   metaspace::BlockListFreeMap map;
       
    35   EXPECT_TRUE(map.all_zero());
       
    36   for (int i = 0; i < map.size(); i ++) {
       
    37     map.set_bit(i);
       
    38     EXPECT_TRUE(map.get_bit(i));
       
    39     map.clr_bit(i);
       
    40     EXPECT_FALSE(map.get_bit(i));
       
    41     EXPECT_TRUE(map.all_zero());
       
    42   }
       
    43 }
       
    44 
       
    45 TEST_VM(metaspace, BlockListFreeMap_mask_find_next_set_bit) {
       
    46   metaspace::BlockListFreeMap map;
       
    47   EXPECT_TRUE(map.all_zero());
       
    48   for (int i = 0; i < map.size(); i ++) {
       
    49     map.set_bit(i);
       
    50     for (int j = 0; j < i; j ++) {
       
    51       int n = map.find_next_set_bit(j);
       
    52       if (j <= i) {
       
    53         EXPECT_EQ(n, i);
       
    54       } else {
       
    55         EXPECT_EQ(n, -1);
       
    56       }
       
    57     }
       
    58     map.clr_bit(i);
       
    59   }
       
    60 }
       
    61