[Alignment] Migrate Attribute::getWith(Stack)Alignment
[llvm-core.git] / unittests / ADT / StringSetTest.cpp
blob17bfa1dd18d23da41ba753020174937227c25db5
1 //===- llvm/unittest/ADT/StringSetTest.cpp - StringSet unit tests ----------===//
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 "llvm/ADT/StringSet.h"
10 #include "gtest/gtest.h"
11 using namespace llvm;
13 namespace {
15 // Test fixture
16 class StringSetTest : public testing::Test {};
18 TEST_F(StringSetTest, IterSetKeys) {
19 StringSet<> Set;
20 Set.insert("A");
21 Set.insert("B");
22 Set.insert("C");
23 Set.insert("D");
25 auto Keys = to_vector<4>(Set.keys());
26 llvm::sort(Keys);
28 SmallVector<StringRef, 4> Expected = {"A", "B", "C", "D"};
29 EXPECT_EQ(Expected, Keys);
32 TEST_F(StringSetTest, InsertAndCountStringMapEntry) {
33 // Test insert(StringMapEntry) and count(StringMapEntry)
34 // which are required for set_difference(StringSet, StringSet).
35 StringSet<> Set;
36 StringMapEntry<StringRef> *Element = StringMapEntry<StringRef>::Create("A");
37 Set.insert(*Element);
38 size_t Count = Set.count(*Element);
39 size_t Expected = 1;
40 EXPECT_EQ(Expected, Count);
41 Element->Destroy();
44 } // end anonymous namespace