1 //===- llvm/unittest/ADT/SetVector.cpp ------------------------------===//
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 //===----------------------------------------------------------------------===//
8 //
9 // SetVector unit tests.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/ADT/SetVector.h"
14 #include "gtest/gtest.h"
15 
16 using namespace llvm;
17 
18 TEST(SetVector, EraseTest) {
19   SetVector<int> S;
20   S.insert(0);
21   S.insert(1);
22   S.insert(2);
23 
24   auto I = S.erase(std::next(S.begin()));
25 
26   // Test that the returned iterator is the expected one-after-erase
27   // and the size/contents is the expected sequence {0, 2}.
28   EXPECT_EQ(std::next(S.begin()), I);
29   EXPECT_EQ(2u, S.size());
30   EXPECT_EQ(0, *S.begin());
31   EXPECT_EQ(2, *std::next(S.begin()));
32 }
33 
34