mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 16:44:36 +02:00

Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com> Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com> Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com> Co-authored-by: Kim Barrett <kim.barrett@oracle.com> Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com> Co-authored-by: Rickard Backman <rickard.backman@oracle.com> Co-authored-by: Roland Westrelin <rwestrel@redhat.com> Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com> Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com> Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com> Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com> Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com> Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com> Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com> Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com> Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
79 lines
1.3 KiB
C++
79 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
|
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
*/
|
|
|
|
#include "precompiled.hpp"
|
|
#include "gc/z/zArray.inline.hpp"
|
|
#include "unittest.hpp"
|
|
|
|
TEST(ZArrayTest, test_add) {
|
|
ZArray<int> a;
|
|
|
|
// Add elements
|
|
for (int i = 0; i < 10; i++) {
|
|
a.add(i);
|
|
}
|
|
|
|
// Check size
|
|
ASSERT_EQ(a.size(), 10u);
|
|
|
|
// Check elements
|
|
for (int i = 0; i < 10; i++) {
|
|
EXPECT_EQ(a.at(i), i);
|
|
}
|
|
}
|
|
|
|
TEST(ZArrayTest, test_clear) {
|
|
ZArray<int> a;
|
|
|
|
// Add elements
|
|
for (int i = 0; i < 10; i++) {
|
|
a.add(i);
|
|
}
|
|
|
|
// Check size
|
|
ASSERT_EQ(a.size(), 10u);
|
|
ASSERT_EQ(a.is_empty(), false);
|
|
|
|
// Clear elements
|
|
a.clear();
|
|
|
|
// Check size
|
|
ASSERT_EQ(a.size(), 0u);
|
|
ASSERT_EQ(a.is_empty(), true);
|
|
|
|
// Add element
|
|
a.add(11);
|
|
|
|
// Check size
|
|
ASSERT_EQ(a.size(), 1u);
|
|
ASSERT_EQ(a.is_empty(), false);
|
|
|
|
// Clear elements
|
|
a.clear();
|
|
|
|
// Check size
|
|
ASSERT_EQ(a.size(), 0u);
|
|
ASSERT_EQ(a.is_empty(), true);
|
|
}
|
|
|
|
TEST(ZArrayTest, test_iterator) {
|
|
ZArray<int> a;
|
|
|
|
// Add elements
|
|
for (int i = 0; i < 10; i++) {
|
|
a.add(i);
|
|
}
|
|
|
|
// Iterate
|
|
int count = 0;
|
|
ZArrayIterator<int> iter(&a);
|
|
for (int value; iter.next(&value);) {
|
|
ASSERT_EQ(a.at(count), count);
|
|
count++;
|
|
}
|
|
|
|
// Check count
|
|
ASSERT_EQ(count, 10);
|
|
}
|