Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / scudo / standalone / tests / vector_test.cpp
blobdc23c2a3471310f7bdbdcc165e43e07e2635f7eb
1 //===-- vector_test.cpp -----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "tests/scudo_unit_test.h"
11 #include "vector.h"
13 TEST(ScudoVectorTest, Basic) {
14 scudo::Vector<int> V;
15 EXPECT_EQ(V.size(), 0U);
16 V.push_back(42);
17 EXPECT_EQ(V.size(), 1U);
18 EXPECT_EQ(V[0], 42);
19 V.push_back(43);
20 EXPECT_EQ(V.size(), 2U);
21 EXPECT_EQ(V[0], 42);
22 EXPECT_EQ(V[1], 43);
25 TEST(ScudoVectorTest, Stride) {
26 scudo::Vector<scudo::uptr> V;
27 for (scudo::uptr I = 0; I < 1000; I++) {
28 V.push_back(I);
29 EXPECT_EQ(V.size(), I + 1U);
30 EXPECT_EQ(V[I], I);
32 for (scudo::uptr I = 0; I < 1000; I++)
33 EXPECT_EQ(V[I], I);
36 TEST(ScudoVectorTest, ResizeReduction) {
37 scudo::Vector<int> V;
38 V.push_back(0);
39 V.push_back(0);
40 EXPECT_EQ(V.size(), 2U);
41 V.resize(1);
42 EXPECT_EQ(V.size(), 1U);