[llvm] r256796 - Add explicit string checks in test

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 4 15:59:15 PST 2016


Author: davidxl
Date: Mon Jan  4 17:59:14 2016
New Revision: 256796

URL: http://llvm.org/viewvc/llvm-project?rev=256796&view=rev
Log:
Add explicit string checks in test

Modified:
    llvm/trunk/unittests/ProfileData/InstrProfTest.cpp

Modified: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=256796&r1=256795&r2=256796&view=diff
==============================================================================
--- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp (original)
+++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp Mon Jan  4 17:59:14 2016
@@ -624,11 +624,24 @@ TEST_F(InstrProfTest, instr_prof_symtab_
       }
       FuncNameStrings += FuncNameStrings2;
 
-      // Now decompress
+      // Now decompress:
       InstrProfSymtab Symtab;
       Symtab.create(StringRef(FuncNameStrings));
 
-      // Now check
+      // Now do the checks:
+      // First sampling some data points:
+      StringRef R = Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames1[0]));
+      ASSERT_EQ(StringRef("func_0"), R);
+      R = Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames1[1]));
+      ASSERT_EQ(StringRef("fooooooooooooooo_0"), R);
+      R = Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames1[998]));
+      ASSERT_EQ(StringRef("func_499"), R);
+      R = Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames1[999]));
+      ASSERT_EQ(StringRef("fooooooooooooooo_499"), R);
+      R = Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames2[100]));
+      ASSERT_EQ(StringRef("BAR_50"), R);
+      R = Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames2[101]));
+      ASSERT_EQ(StringRef("BlahblahBlahblahBar_50"), R);
       for (int I = 0; I < 10 * 1024; I++) {
         std::string N[4];
         N[0] = FuncNames1[2 * I];




More information about the llvm-commits mailing list