[ubsan] Change ubsan-unique-traps to use nomerge instead of counter (#117651)
[llvm-project.git] / libcxxabi / test / unittest_demangle.pass.cpp
blob3f86e9c49a8a5f84e32cabf7e21baa05a47eb3fa
1 //===----------------------------------------------------------------------===//
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 // UNSUPPORTED: c++03
10 // ADDITIONAL_COMPILE_FLAGS: -Wno-unused-function
12 #include <cassert>
13 #include <utility>
15 #include "../src/demangle/ItaniumDemangle.h"
17 void testPODSmallVector() {
18 { // {push/pop}_back
19 itanium_demangle::PODSmallVector<int, 1> PSV;
20 PSV.push_back(0);
21 PSV.push_back(1);
22 PSV.push_back(2);
23 PSV.push_back(3);
24 for (int i = 0; i < 4; ++i)
25 assert(PSV[i] == i);
26 PSV.pop_back();
27 for (int i = 0; i < 3; ++i)
28 assert(PSV[i] == i);
29 PSV.pop_back();
30 PSV.pop_back();
31 assert(!PSV.empty() && PSV.size() == 1);
32 PSV.pop_back();
33 assert(PSV.empty() && PSV.size() == 0);
37 itanium_demangle::PODSmallVector<int, 1> PSV1;
38 PSV1.push_back(1);
39 PSV1.push_back(2);
40 PSV1.push_back(3);
42 itanium_demangle::PODSmallVector<int, 1> PSV2;
43 std::swap(PSV1, PSV2);
44 assert(PSV1.size() == 0);
45 assert(PSV2.size() == 3);
46 int i = 1;
47 for (int x : PSV2) {
48 assert(x == i);
49 ++i;
51 assert(i == 4);
52 std::swap(PSV1, PSV2);
53 assert(PSV1.size() == 3);
54 assert(PSV2.size() == 0);
55 i = 1;
56 for (int x : PSV1) {
57 assert(x == i);
58 ++i;
60 assert(i == 4);
64 itanium_demangle::PODSmallVector<int, 10> PSV1;
65 itanium_demangle::PODSmallVector<int, 10> PSV2;
66 PSV1.push_back(0);
67 PSV1.push_back(1);
68 PSV1.push_back(2);
69 assert(PSV1.size() == 3);
70 assert(PSV2.size() == 0);
71 std::swap(PSV1, PSV2);
72 assert(PSV1.size() == 0);
73 assert(PSV2.size() == 3);
74 int i = 0;
75 for (int x : PSV2) {
76 assert(x == i);
77 ++i;
79 for (int x : PSV1) {
80 assert(false);
81 (void)x;
86 int main(int, char**) {
87 testPODSmallVector();
88 return 0;