1 //===----- SymbolStringPoolTest.cpp - Unit tests for SymbolStringPool -----===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h" 11 #include "gtest/gtest.h" 12 13 using namespace llvm; 14 using namespace llvm::orc; 15 16 namespace { 17 18 TEST(SymbolStringPool, UniquingAndEquality) { 19 SymbolStringPool SP; 20 auto P1 = SP.intern("hello"); 21 22 std::string S("hel"); 23 S += "lo"; 24 auto P2 = SP.intern(S); 25 26 auto P3 = SP.intern("goodbye"); 27 28 EXPECT_EQ(P1, P2) << "Failed to unique entries"; 29 EXPECT_NE(P1, P3) << "Inequal pooled symbol strings comparing equal"; 30 } 31 32 TEST(SymbolStringPool, ClearDeadEntries) { 33 SymbolStringPool SP; 34 { 35 auto P1 = SP.intern("s1"); 36 SP.clearDeadEntries(); 37 EXPECT_FALSE(SP.empty()) << "\"s1\" entry in pool should still be retained"; 38 } 39 SP.clearDeadEntries(); 40 EXPECT_TRUE(SP.empty()) << "pool should be empty"; 41 } 42 43 } 44