Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/utilities/chunkedList.cpp
32285 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "utilities/chunkedList.hpp"26#include "utilities/debug.hpp"2728/////////////// Unit tests ///////////////2930#ifndef PRODUCT3132template <typename T>33class TestChunkedList {34typedef ChunkedList<T, mtOther> ChunkedListT;3536public:37static void testEmpty() {38ChunkedListT buffer;39assert(buffer.size() == 0, "assert");40}4142static void testFull() {43ChunkedListT buffer;44for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {45buffer.push((T)i);46}47assert(buffer.size() == ChunkedListT::BufferSize, "assert");48assert(buffer.is_full(), "assert");49}5051static void testSize() {52ChunkedListT buffer;53for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {54assert(buffer.size() == i, "assert");55buffer.push((T)i);56assert(buffer.size() == i + 1, "assert");57}58}5960static void testClear() {61ChunkedListT buffer;6263buffer.clear();64assert(buffer.size() == 0, "assert");6566for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {67buffer.push((T)i);68}69buffer.clear();70assert(buffer.size() == 0, "assert");7172for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {73buffer.push((T)i);74}75buffer.clear();76assert(buffer.size() == 0, "assert");77}7879static void testAt() {80ChunkedListT buffer;8182for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {83buffer.push((T)i);84assert(buffer.at(i) == (T)i, "assert");85}8687for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {88assert(buffer.at(i) == (T)i, "assert");89}90}9192static void test() {93testEmpty();94testFull();95testSize();96testClear();97testAt();98}99};100101class Metadata;102103void TestChunkedList_test() {104TestChunkedList<Metadata*>::test();105TestChunkedList<size_t>::test();106}107108#endif109110111